Reputation: 946
I have a web application which uses Spring. Bean definitions and spring configuration for the web application are declared in webapp-spring.xml. This web application uses a library as its dependency. Let us say the library is called data-access.jar. This library is on the web application's classpath. The web application is configured to initialise spring context by the usual web.xml configuration:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:webapp-spring.xml</param-value>
</context-param>
The data-access.jar library also has its own spring beans xml definition data-access-spring.xml embedded within it (directly at the root level) for its internal use of Spring dependency injection.
When the web application context initialisation happens on starting the container (Tomcat), I would like Spring to initialise context using data-access-spring.xml along with web-app-spring.xml. How do I do this?
I tried following which didn't work:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:web-app-spring.xml,classpath*:data-access-spring.xml</param-value>
</context-param>
Spring silently ignores data-access-spring.xml and only initialises the bean definitions from web-app-spring.xml.
Upvotes: 0
Views: 930
Reputation: 11363
classpath*:
will basically ignore files which don't match the pattern. But your syntax is correct. So it looks like data-access-spring.xml
isn't being found. Are you sure it's at the root?
You could also use patterns, btw, e.g. classpath*:*-spring.xml
, but that shouldn't help you here. classpath*:web-app-spring.xml,classpath*:**/data-access-spring.xml
might if it's not at the root.
Upvotes: 1