web容器中實例化spring相關配置解析
文章主要探究了web容器中實例化spring的相關配置簡單介紹,接下來我們看看具體內容。
web容器中實例化spring相關配置說明:
要想在web容器實例化時加載spring容器,web.xml文件中配置如下:
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:bean.xml</param-value> </context-param> <!-- 對Spring容器進行實例化的監(jiān)聽器s --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
說明:
默認情況下spring實例化時加載的是/WEB-INF/下的applicationContext.xml
<param-name>contextConfigLocation</param-name>
<param-value>classpath:bean.xml</param-value>指定了spring需要加載的文件(類路徑下的bean.xml文件)
如果配置文件有多個配置如下:
<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:conf/spring/applicationContext_core*.xml, classpath*:conf/spring/applicationContext_dict*.xml, classpath*:conf/spring/applicationContext_hibernate.xml, classpath*:conf/spring/applicationContext_staff*.xml, classpath*:conf/spring/applicationContext_security.xml classpath*:conf/spring/applicationContext_modules*.xml classpath*:conf/spring/applicationContext_cti*.xml classpath*:conf/spring/applicationContext_apm*.xml </param-value> </context-param>
或者(使用空格隔開,如下配置:)
<CONTEXT-PARAM> <PARAM-NAME>contextConfigLocation</PARAM-NAME> <PARAM-VALUE> applicationContext-database.xml applicationContext.xml </PARAM-VALUE> </CONTEXT-PARAM>
總結
以上就是本文關于web容器中實例化spring相關配置解析的全部內容,希望對大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站:
《Spring的實例工廠方法和靜態(tài)工廠方法實例代碼》
如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!
相關文章
IDEA連接mysql數(shù)據(jù)庫報錯的解決方法
這篇文章主要介紹了IDEA連接mysql數(shù)據(jù)庫報錯的解決方法,文中有非常詳細的圖文示例,對出現(xiàn)Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘ prope報錯的小伙伴們很有幫助喲,需要的朋友可以參考下2021-05-05詳解springboot中redis的使用和分布式session共享問題
這篇文章主要介紹了詳解springboot中redis的使用和分布式session共享問題,詳細的介紹了解決分布式系統(tǒng)的session如何共享問題,有興趣的可以了解一下2017-11-11SpringBoot中GlobalExceptionHandler異常處理機制詳細說明
Spring Boot的GlobalExceptionHandler是一個全局異常處理器,用于捕獲和處理應用程序中發(fā)生的所有異常,這篇文章主要給大家介紹了關于Java中GlobalExceptionHandler異常處理機制的相關資料,需要的朋友可以參考下2024-03-03Spring?MVC異步上傳、跨服務器上傳和文件下載功能實現(xiàn)
這篇文章主要介紹了Spring?MVC異步上傳、跨服務器上傳和文件下載功能實現(xiàn),本文通過示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-07-07