After splitting into multiple, the bean's configuration can be placed in one of the files, and it does not have to be duplicated in each file.
Multiple files, such as applicationcontext-datasource.xml (data source), Applicationcontext-hibernate.xml, Applicationcontext-service.xml
You only need to configure in Web. xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/web-inf/applicationcontext-*.xml
</param-value>
</context-param>
This way, spring can load multiple files at the same time.
It can also be implemented in Struts-config.xml:
<plug-in
Classname= "Org.springframework.web.struts.ContextLoaderPlugIn" >
<set-property property= "Contextconfiglocation"
Value= "/web-inf/classes/spring-model-config.xml,/web-inf/classes/spring-web-config.xml"/>
</plug-in>
Load multiple configuration files as plug-ins.
In fact, they all have the same principle, as long as they have the desired bean in memory.
A bean in one configuration file wants to reference a bean in another file, you can use the
<property name= "DataSource" ><ref bean= "DataSource"/></property>
Get it like this. Attention is bean=, not local=.
If you are using local= to find beans from the current configuration file, use bean= if the bean is in a different file.
Summary: It is best to maintain a applicationcontext.xml original configuration file and import other configuration files in the original file, so that it is convenient to call all the beans, such as when the test can be context = new Classpathxmlapplicationcontext ("Applicationcontext.xml"); load all beans.