【问题标题】:Make a bean unautowireable or that disposes of it self?使 bean 无法自动连接或自行处理?
【发布时间】:2013-02-01 16:53:00
【问题描述】:

我们需要一个spring bean

防止框架使用 @Autowired -ing 它。

一旦它完成它的工作,它就会自我毁灭?

bean 大致是这样的:

public final class Registrar implements ApplicationListener<SOFrameworkInitializedEvent>

因此,在它收到此 1 次事件后,执行工作并离开。我们使用的是 Spring 3.0.7。

【问题讨论】:

标签: spring


【解决方案1】:

在 bean 定义 XML 中使用 autowire-candidate 属性,例如:

  <bean id="MyBean" class="com.acme.SimpleTestServiceImpl" autowire-candidate="false"/>

【讨论】:

    猜你喜欢
    • 2022-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-22
    • 2016-09-27
    • 1970-01-01
    • 2019-03-15
    相关资源
    最近更新 更多