@EnableConfigurationProperties

参考:https://www.jianshu.com/p/7f54da1cb2eb

使用 @ConfigurationProperties 注解的类生效。

如果一个配置类只配置@ConfigurationProperties注解,而没有使用@Component,那么在IOC容器中是获取不到properties 配置文件转化的bean。
==> @EnableConfigurationProperties 相当于把使用 @ConfigurationProperties 的类进行了一次注入。
@ConfigurationProperties 与 @EnableConfigurationProperties 的关系:
  
@EnableConfigurationProperties :     
/**
* Enable support for {@link ConfigurationProperties} annotated beans.
* {@link ConfigurationProperties} beans can be registered in the standard way (for
* example using {@link Bean @Bean} methods) or, for convenience, can be specified
* directly on this annotation.
*
* @author Dave Syer
*/
@EnableConfigurationProperties注解应用到你的@Configuration时, 任何被@ConfigurationProperties注解的beans将自动被Environment属性配置。 这种风格的配置特别适合与SpringApplication的外部YAML配置进行配合使用。
 @EnableConfigurationProperties=@ConfigurationProperties+@Component
posted @ 2019-06-23 12:48  一条有梦想的海洋咸鱼  阅读(2531)  评论(0编辑  收藏  举报