configurationproperties注解 @Compoment
时间: 2023-12-15 16:44:30 浏览: 158
引用中提到,可以在PropertiesTest类上添加@Component注解,将其注册到IOC容器中。@Component注解是Spring框架提供的一个通用的注解,用于标识一个类是一个组件,需要被Spring进行管理。被@Component注解标注的类会被自动扫描并注册到IOC容器中,可以在其他地方使用@Autowired注解进行依赖注入。因此,如果想要使用@ConfigurationProperties注解绑定配置文件的属性到PropertiesTest类中,并且希望PropertiesTest类被IOC容器管理,可以在PropertiesTest类上添加@Component注解。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [【springboot】springboot 注解之@ConfigurationProperties](https://blog.csdn.net/zzd13546036394/article/details/129760489)[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^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [Spring-Boot中properties的使用:@Component与@Autowired注解](https://blog.csdn.net/fyyyr/article/details/83621188)[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^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文