Does anyone know how to specify a bean as non lazy when using annotations to configure the bean?
+1
A:
You cannot do that with annotation, only with XML. The question is, have you set the default to be lazy init:
<beans default-lazy-init="true">
<!-- no beans will be pre-instantiated... -->
</beans>
The xml for setting a bean to be initialized on context initialization is
<bean id="lazy" class="com.foo.CheapToCreateBean" lazy-init="false"/>
and this is the default behavior.
David Rabinowitz
2009-06-22 16:21:05
that is what I was worried about, I could not see the annotation for it... I wonder why they don't support it?
Michael Wiles
2009-06-23 09:38:08
I don;t know either, but you can add a request here http://jira.springframework.org/browse/SPR
David Rabinowitz
2009-06-23 10:25:25
+2
A:
Beans are not lazy by default. However as far as annotations are concerned it seems like currently annotations do not support it. http://forum.springsource.org/showthread.php?t=62931
Spring's next version though seem to have something in store http://jira.springframework.org/browse/SJC-263
Priyank
2009-06-26 13:30:28