在多模块 Maven 项目中精炼 Spring Bean?
由于某种原因,我对此一片空白。我有一个多模块 Spring/Maven 项目。在 module1 中,我定义了一个名为“info”的单例 bean,它在 module1 中工作得很好。
然而,该项目中的 module2(依赖于 module1)对“info”bean 的属性值进行了改进。 Module2的Spring配置已经包含Module1的配置。我应该使用什么 Spring 配置来设置后续模块中定义的“info”bean 的属性?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 Spring 2.5 开始,出现了 PropertyOverrideConfigurer。也许这就是您正在寻找的
http: //static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-factory-overrideconfigurer
此页面上有一个小示例
http://ondra.zizka.cz/stranky/programovani/java /howto-substitutions_in_spring_configuration-tutorial.texy
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
在 module2 中创建一个新的“info”bean,并根据模块 2 的特定需求对其进行配置。
您可以在模块 2 配置中执行类似的操作:
这应该将正确的“信息”注入到依赖的 bean 中
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:
This should inject the right "info" into the dependent beans