在多模块 Maven 项目中精炼 Spring Bean?

发布于 2024-12-05 05:02:18 字数 234 浏览 2 评论 0原文

由于某种原因,我对此一片空白。我有一个多模块 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷…雨湿花 2024-12-12 05:02:18

在 module2 中创建一个新的“info”bean,并根据模块 2 的特定需求对其进行配置。
您可以在模块 2 配置中执行类似的操作:

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

这应该将正确的“信息”注入到依赖的 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:

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文