开发者

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 projec开发者_如何学Got (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?


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜