Reputation: 13877
my (maven based) project is built out of a couple of modules. Basically there's a Core module and a couple of modules which make use of it to provide various services to the outside. The "glue" between these modules is the "parent" module. The "parent" module isn't supposed to hold any code. Something like this:
What I'd like to do is to use Spring IoC to inject / autowire the Core parts into the Service parts. But I can't seem to find a way to configure that. Or at least I can't seem to find a way to avoid redundant IoC configuration within the Service parts.
To be more specific - using the example from the Spring documentation - assume that would be the configuration for one of the service modules - how could I move the example.SimpleMovieCatalog
configuration parts into the Core module without loosing the ability to inject them within one of the "sibling" modules?
<?xml version="1.0" encoding="UTF-8"?>
<beans...>
<context:annotation-config/>
<bean class="example.SimpleMovieCatalog">
<qualifier value="main"/>
</bean>
<bean class="example.SimpleMovieCatalog">
<qualifier value="action"/>
</bean>
<bean id="movieRecommender" class="example.MovieRecommender"/>
</beans>
Upvotes: 4
Views: 3848
Reputation: 13877
I finally figured out a way which seems to work for now:
/META-INF/spring-<module>.xml
context:component-scan
will not work properlySome remarks
<import resource="classpath*:META-INF/spring-core.xml" />
is understood by my IDE, but doesn't give the desired results at all (e.g. breaks context:component-scan
configurations)Upvotes: 5