How spring's applicationcontext.xml automatically loads

Source: Internet
Author: User

A Web project that automatically loads the configuration file only for XML, and wants to load the other. XML must be configured inside XML.

When using spring, a bean container is needed to manage all the beans, and all the beans are written in Applicationcontext.xml, which is set in Web. Xml.

1 <Context-param>2     <Param-name>Contextconfiglocation</Param-name>3     <Param-value>4 /web-inf/dispatcherservlet-servlet.xml5     </Param-value>6 </Context-param>7 8 <Listener>9     <Listener-class>Ten Org.springframework.web.context.ContextLoaderListener One     </Listener-class> A </Listener>

<context-param> is optional, if not, load applicationcontext.xml, or you can use it to specify a different configuration file.

1 <Context-param>2     <Param-name>Contextconfiglocation</Param-name>3     <Param-value>Classpath:spring.xml,classpath:spring-mybatis.xml</Param-value>4 </Context-param>

So, write a applicationcontext.xml at the root of the class and configure the spring stuff.

How spring's applicationcontext.xml automatically loads

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.