Dave
Dave

Reputation: 21924

Refining a Spring Bean in a multi-module Maven project?

I am drawing a blank on this for some reason. I have a multi-module Spring/Maven project. In module1 I define a singleton bean called "info" and it works within module1 just fine.

However module2 in this project (which depends on module1) has improvements on property values for the "info" bean. Module2's Spring configuration already includes Module1's configuration. What is the Spring configuration I should use to set properties on the "info" bean defined in this subsequent module?

Upvotes: 3

Views: 1709

Answers (2)

Biju Kunjummen
Biju Kunjummen

Reputation: 49915

Create a new "info" bean in module2, configuring it the way specific to the needs of module 2. You would do something like this in your module 2 configuration:

<import resource="classpath:/META-INF/module1-config.xml"/>
<bean name="info" class="Module1class"/>

This should inject the right "info" into the dependent beans

Upvotes: 0

user948392
user948392

Reputation: 186

Since Spring 2.5 there is a PropertyOverrideConfigurer. Maybe that's what you are searching for

http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-factory-overrideconfigurer

There is a small example on this page http://ondra.zizka.cz/stranky/programovani/java/howto-substitutions_in_spring_configuration-tutorial.texy

Upvotes: 1

Related Questions