Analysis of spring-related configuration instantiation in web containers, webspring
This article briefly introduces the configuration of instantiating spring in web containers. Next, let's take a look at the specific content.
Configuration instructions for instantiating spring in web containers:
To load the spring container when the web container is instantiated, configure the following in the web. xml file:
<Context-param> <param-name> contextConfigLocation </param-name> <param-value> classpath: bean. xml </param-value> </context-param> <! -- Instantiate the listener s for the Spring container --> <listener-class> org. springframework. web. context. ContextLoaderListener </listener-class> </listener>
Note:
By default, the applicationContext. xml under/WEB-INF/is loaded during spring instantiation.
<Param-name> contextConfigLocation </param-name>
<Param-value> classpath: bean. xml </param-value> specifies the file to be loaded by spring (the bean. xml file under the class path)
If the configuration file has multiple configurations:
<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>
Or (use spaces to separate them, as shown below :)
<CONTEXT-PARAM> <PARAM-NAME>contextConfigLocation</PARAM-NAME> <PARAM-VALUE> applicationContext-database.xml applicationContext.xml </PARAM-VALUE> </CONTEXT-PARAM>
Summary
The above is all about parsing spring-related configuration instantiation in web containers. I hope it will be helpful to you. Interested friends can continue to refer to this site:
《Code explanation of Spring bean instantiation Method"
《Spring instance factory method and static factory Method Instance code"
《Differences Between Spring Singleton Bean and Singleton Mode"
If you have any shortcomings, please leave a message. Thank you for your support!