@EnableConfigurationProperties({LogdcConfig.class})
时间: 2023-11-09 11:01:18 浏览: 38
@EnableConfigurationProperties({LogdcConfig.class})是一个Spring Boot注解,用于将指定的配置类注册为可配置的Bean。在这个例子中,LogdcConfig类将被注册为可配置的Bean,可以通过@ConfigurationProperties注解来读取外部配置文件中的属性值。
@ConfigurationProperties注解用于将外部配置文件中的属性值绑定到对应的属性字段上。通过在属性字段上添加@ConfigurationProperties注解,并指定前缀,Spring Boot会自动将配置文件中对应前缀的属性值绑定到该字段上。
例如,假设在配置文件中有以下属性:
logdc.config.name=example
logdc.config.maxSize=100
可以通过以下方式将这些属性值绑定到LogdcConfig类的对应字段上:
@ConfigurationProperties(prefix = "logdc.config")
public class LogdcConfig {
private String name;
private int maxSize;
// Getter and Setter methods
}
在上述例子中,name字段的值将被绑定为"example",maxSize字段的值将被绑定为100。
相关问题
@EnableConfigurationProperties(SecurityProperties.class)
@EnableConfigurationProperties(SecurityProperties.class)是一个Spring Boot提供的注解,用于启用应用对@ConfigurationProperties注解的支持。通过使用该注解,可以将带有@ConfigurationProperties注解的bean注册到容器中,并且可以通过标准的方式,如使用@Bean注解来注册或通过@EnableConfigurationProperties注解注册到容器中。
在具体的实现中,@EnableConfigurationProperties注解会委托给@EnableConfigurationPropertiesImportSelector类来完成配置属性bean的注册任务。该类会扫描类路径下的所有带有@ConfigurationProperties注解的类,并将它们注册到容器中。
在Spring Security中的SecurityAutoConfiguration类中,我们可以看到@EnableConfigurationProperties(SecurityProperties.class)的使用。该类是Spring Security核心自动配置类,它使用了@EnableConfigurationProperties注解来启用对SecurityProperties类的支持,将其注册到容器中。
总结来说,@EnableConfigurationProperties(SecurityProperties.class)是一个用于启用应用对@ConfigurationProperties注解支持的注解,可以将带有@ConfigurationProperties注解的bean注册到容器中。在Spring Security中的SecurityAutoConfiguration类中就是通过该注解来启用对SecurityProperties类的支持。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Spring Boot : @EnableConfigurationProperties -- 注册使用 @ConfigurationProperties 的 bean](https://blog.csdn.net/andy_zhang2007/article/details/90286737)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [2、spring security流程解读之自动配置类](https://blog.csdn.net/u012153127/article/details/118195628)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
@EnableConfigurationProperties(RedisProperties.class)
@EnableConfigurationProperties(RedisProperties.class)是一个注解,用于启用将指定的配置类作为属性配置的来源。在这个例子中,它被用于将RedisProperties作为属性配置注入到RedissonAndBloomConfig类中。这样一来,RedisProperties类中的属性就会根据配置文件中以"spring.redis"为前缀的属性进行赋值。通过使用@EnableConfigurationProperties(RedisProperties.class),我们可以在RedissonAndBloomConfig类中自动获取RedisProperties对象并使用它来配置RedissonClient对象。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [@ConfigurationProperties和@@EnableConfigurationProperties](https://blog.csdn.net/IT_tyro/article/details/122391626)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)