Reputation:
I would like to have step-by-step information on :
how to split the ApplicationContext file (eg.: myapp-servlet.xml) into multiple XML files in Spring with some examples ?
I have tried configuring web.xml with "ContextLoaderListener" and have contextConfigLocation like :
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value> /WEB-INF/business-services.xml </param-value>
</init-param>
but it is creating problems.
Please give me in-detail explaination on how to do this.
Thanks in advance !
Upvotes: 4
Views: 15312
Reputation: 2514
What I like to do, if I have multiple context files, is to have my base context class import the other pieces via the import tag.
<import resource="applicationContext-otherStuff.xml"/>
We typically use this model, to keep out datasource configuration separate from the bean instantiations.
Upvotes: 12
Reputation: 6630
e.g. with:
<param-value>classpath*:spring/persistence/*.xml, classpath*:spring/*.xml</param-value>
the paths depend on your locations of the splitted .xml
Example with WEB-INF Directories
<param-value>/WEB-INF/daoContext.xml /WEB-INF/applicationContext.xml</param-value>
sidenote: seems to work without ','
Reference:
Upvotes: 3