I have a Spring web application with two contexts: one (applicationContext
) built by ContextLoaderListener
and a second (webContext
) b
I think the actual answer is that you may want to configure your app differently (so that you only have one context) I think in your web.xml you need to do something like this :
example
org.springframework.web.servlet.DispatcherServlet
1
contextConfigLocation
classpath:/META-INF/applicationSpringConfig.xml
But to answer the deeper question. Someone else points out that you can use includes in your spring file (indeed in the above you can have more than one springconfig specified in your dispatcher servlet). But when you include other context files you do not share instances of beans, only definitions.
Modularising Spring applications has been the only real downside of spring in comparison with EJB etc. That led spring into using OSGi. And the answer to your underlying question of how to share spring context, officially you share spring bean instances between contexts using OSGi (spring dm)