创建使用基于注解配置的延迟初始化的Spring bean [英] Creating lazily initialized Spring beans using annotation based configuration
问题描述
我使用Spring的 @Component
注释配置许多豆子在我的Spring 3.0的应用程序。我想知道,如果它可以构建一些豆类懒洋洋地 - 尤其是原型
豆类
要申报延迟初始化的bean可以使用<一个href=\"http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/context/annotation/Lazy.html\"><$c$c>@Lazy$c$c>注释。
但是请注意,这是没有道理的原型
豆类 - 他们不能被急切地初始化,因此没有必要将它们标记懒<。 / p>
I am using Spring's @Component
annotation to configure many of the beans in my Spring 3.0 application. I would like to know if it's possible to construct some of these beans lazily - especially the prototype
beans?
To declare lazy-initialized bean you can use @Lazy
annotation.
Note, however, that it doesn't make sense for prototype
beans - they can't be eagerly initialized, so there is no need to mark them lazy.
这篇关于创建使用基于注解配置的延迟初始化的Spring bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!