前言
在传统的xml模式得Spring中,我们注册一个Bean如果需要使用懒加载(表示该bean在容器初始化的时候不进行初始化)我们通过bean标签里面的lazy-init属性进行设置,在Spring3.0之后提供了@Lazy注解代替此方式。
@Lazy源码
@Target({
ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Lazy {
/**
* Whether lazy initialization should occur.
*/
boolean value()