1.@EnableConfigurationProperties 可以将配置文件的属性自动注入到bean里面 一般配合@ConfigurationProperties使用
2、@EnableAsync 配合@Async使用 是的方法异步执行
关键作用@Import:
1.@Import:用来导入一个或多个类(交给spring容器托管),或者配置类
2.实现ImportSelector接口,将这个类交给spring容器管理 和@Import一样作用
1.实现一个注解了@Import的注解步骤
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({MyImportSelector.class})
public @interface EnableLog {
String name();
}
2.可在ImportSelector接口的实现类通过
annotationMetadata.getAllAnnotationAttributes(EnableLog.class.getName()) 获取EnableLog注解的属性值
3.最后@EnableLog(name='xxxxx')注解在配置类/启动类上。
3.ImportBeanDefinitionRegistrar 接口 在这里可以获取BeanDefinitionRegistry, 可以往容器中动态注入bean