A, @ EnableConfigurationProperties annotation role
Support for the bean can @ConfigurationProperties annotations.
Simple to understand: May not be annotated @Bean or other bean registered in our class configuration, the register to comment Bean container through @EnableConfigurationProperties the configuration class.
Simple to understand: May not be annotated @Bean or other bean registered in our class configuration, the register to comment Bean container through @EnableConfigurationProperties the configuration class.
Second, the use of case notes @ EnableConfigurationProperties
For example RedisAutoConfiguration class, you need to register RedisProperties configuration class is this way.
@Configuration @ConditionalOnClass(RedisOperations.class) @EnableConfigurationProperties(RedisProperties.class) @Import({ LettuceConnectionConfiguration.class, JedisConnectionConfiguration.class }) public class RedisAutoConfiguration { ... }
No other annotations on RedisProperties @Component plus class, may be registered in the Spring container
@ConfigurationProperties(prefix = "spring.redis") public class RedisProperties { ... }