web container instantiates spring related configuration resolution

  • 2020-12-18 01:49:51
  • OfStack

This article explores the configuration associated with instantiating spring in the web container. Let's take a look at the details.

spring instantiation in web container

To load the spring container when the web container is instantiated, the configuration in the ES12en.xml file is as follows:


<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:bean.xml</param-value>
</context-param>
<!--  right Spring The listener that the container instantiates s -->
<listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Description:

By default, spring instantiation loads applicationContext.xml under/WEB-ES22en /

< param-name > contextConfigLocation < /param-name >

< param-value > classpath:bean.xml < /param-value > Specifies the file that spring needs to load (bean.xml file under the classpath)

If the profile 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_cti*.xml
      classpath*:conf/spring/applicationContext_apm*.xml
    </param-value>
  </context-param>

Or (separated by Spaces, configured as follows :)


     <CONTEXT-PARAM>
     <PARAM-NAME>contextConfigLocation</PARAM-NAME>
     <PARAM-VALUE>
        applicationContext-database.xml applicationContext.xml
     </PARAM-VALUE> 
   </CONTEXT-PARAM>

conclusion

That is the end of this article on the web container instantiation of spring related configuration parsing, I hope to help you. Those who are interested can continue to see this site:

Spring - How to Instantiate bean - Code Detail

Spring instance Factory Method and Static Factory Method Instance Code

Discussion on the Difference between Spring Singleton Bean and Singleton Pattern

If there is any deficiency, please let me know. Thank you for your support!


Related articles: