【问题标题】:How to create birt runtime object as singleton in spring [closed]如何在spring中将birt运行时对象创建为单例[关闭]
【发布时间】:2014-07-22 06:49:37
【问题描述】:

我想创建一个单例 birt 对象,因为 birt 对象是重量级对象,我是这项技术的新手,所以任何帮助都会得到帮助。

【问题讨论】:

    标签: java spring birt singleton-type


    【解决方案1】:

    在应用上下文中对这个对象使用singleton scope

    <bean id="accountController" class="com.foo.DefaultAccountController" />
    
    <!-- (singleton scope is the default) -->
    <bean id="accountService" class="com.foo.DefaultAccountService" />
    

    然后你可以像这样在一些声明的 bean 中自动装配依赖:

    public class DefaultAccountController {
        @Autowired
        private DefaultAccountService accService;
    
        ...
    }
    

    详细信息可见Spring documentation

    【讨论】:

    • 如何将该对象传递给其他类。
    • @user3060230 我更新答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-29
    • 2018-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多