Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring import application context from another project

I have 2 projects, one of them is included in the other one build path, both of them have his own application context defining his beans.

I want to manage Global Transactions so I have to have in one application context the import of both of them, but I didn't find the way to do that.

It is possible have 2 application context in different project and import one of them to the other.

If there is no possible which would be the best solution?

I have think in become the 2 projects in 1.

like image 730
Michel Avatar asked Jun 24 '11 13:06

Michel


2 Answers

Yes it is possible to import; in one of your appcontext xmls:

<beans>

    <import 
        resource="classpath*:/META-INF/whatever/root/to/otherAppContext.xml" />

    <bean id="beanA" class="..."/>
    <bean id="beanB" class="..."/>

</beans>
like image 75
abalogh Avatar answered Nov 16 '22 14:11

abalogh


This oldish Spring blog post describes pretty much exactly what you're trying to do.

http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/

like image 6
Nick Avatar answered Nov 16 '22 14:11

Nick