[英]Creating lazily initialized Spring beans using annotation based configuration
I am using Spring's @Component
annotation to configure many of the beans in my Spring 3.0 application. 我使用Spring的@Component
注释来配置Spring 3.0应用程序中的许多bean。 I would like to know if it's possible to construct some of these beans lazily - especially the prototype
beans? 我想知道是否可以懒惰地构建一些这些豆 - 特别是prototype
豆?
Lazy initialization isn't an option in the context of prototype-scoped beans. 在原型范围的bean的上下文中,延迟初始化不是一个选项。 Those beans are instantiated and initialized on demand every time something asks for them, so they are, by nature, lazily initialized. 每当有东西要求时,这些bean都会根据需要进行实例化和初始化,因此它们本质上是懒洋洋地初始化的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.