The article mainly explores the brief introduction to the relevant configuration of instantiated spring in web containers. Let's take a look at the specific content.
Instantiated spring configuration instructions in web container:
To load the spring container when instantiating the web container, the configuration in the web.xml file is as follows:
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:bean.xml</param-value></context-param><!-- Listeners for instantiating Spring containers --><listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>
illustrate:
By default, when spring is instantiated, the applicationContext.xml is loaded under /WEB-INF/
<param-name>contextConfigLocation</param-name>
<param-value>classpath:bean.xml</param-value> specifies the file that spring needs to be loaded (bean.xml file under the classpath)
If the configuration file has multiple configurations as follows:
<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_modules*.xml, classpath*:conf/spring/applicationContext_modules*.xml, classpath*:conf/spring/applicationContext_modules*.xml classpath*:conf/spring/applicationContext_cti*.xml classpath*:conf/spring/applicationContext_apm*.xml </param-value> </context-param>
Or (using spaces separated, as follows:)
<CONTEXT-PARAM> <PARAM-NAME>contextConfigLocation</PARAM-NAME> <PARAM-VALUE> applicationContext-database.xml applicationContext.xml </PARAM-VALUE> </CONTEXT-PARAM>
Summarize
The above is all about instantiating spring-related configuration parsing in web containers. I hope it will be helpful to everyone. Interested friends can continue to refer to this site:
" Detailed explanation of the method and code of Spring instantiation bean "
" Spring's instance factory method and static factory method example code "
" A Brief Discussion on the Difference between Spring Singleton Bean and Singleton Pattern "
If there are any shortcomings, please leave a message to point it out. Thank you friends for your support for this site!