首页 > 其他 > 详细

@EnableConfigurationProperties

时间:2019-06-23 13:18:38      阅读:80      评论:0      收藏:0      [点我收藏+]

参考: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

@EnableConfigurationProperties

原文:https://www.cnblogs.com/luojiabao/p/11072406.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!