Spring注解之@Lazy简介说明
下文笔者讲述Spring注解@Lazy的功能简介说明
@Lazy功能简介
用于标识bean是否需要延迟加载
当bean上面标识了lazy注解后
在Spring容器初始化时,是不会加载此bean
等待使用时,再进行加载
在Spring中使用Lazy注解
可减少Spring IOC容器的加载时间
也可以用于减少循环依赖
@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() default true;
}
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


