There are two WARs deployed in Tomcat (or other server), foo1.war and foo2.war.
All spring beans are defined in foo1.war, but is it possible to get these spring beans in the servlet that deployed in foo2.war?
I cannot just use WebApplicationContextUtils to get the WebApplicationContext, right? They are different WAR.
thanks
Technically, you can get the
WebApplicationContextof the other app, if you expose the servlet context and callservletContext.getContext("/otherapp").getAttribute(..), but that’s ugly.You can have instances of the same bean definitions if you simply move the common definitions to a
common.xmland include it in both projects.If you need to communicate some data betweent the two apps, use another mechanism: web services (soap, rest), messaging (jmx).