@Configuration

表示该类为“配置类”,可替换xml配置文件。与@Component不同的是,@Configuration会生成CGLIB代理class。

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Configuration {
	@AliasFor(annotation = Component.class)
	String value() default "";
}

@Bean

主要定义在@Configuration注释的类中的方法上,而这些方法将会被AnnotationConfigApplicationContext 或 AnnotationConfigWebApplicationContext类进行扫描。
这个配置等同于在xml配置里配置的bean。

@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Bean {
	@AliasFor("name")
	String[] value() default {};
	@AliasFor("value")
	String[] name() default {};
	@Deprecated
	Autowire autowire() default Autowire.NO;
	boolean autowireCandidate() default true;
	String initMethod() default "";
	String destroyMethod() default AbstractBeanDefinition.INFER_METHOD;
}

@Lazy

主要用于修饰Spring Bean类,作用是指定该Bean是否取消预初始化。

@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Lazy {
	boolean value() default true;
}

积累点点滴滴,一步一脚印,加油

posted on 2019-04-20 20:32  寒翼绵羊  阅读(122)  评论(0编辑  收藏  举报