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