not registered via @enableconfigurationproperties or marked as spring component
时间: 2023-04-17 08:04:14 浏览: 278
这个错误通常是因为在Spring Boot应用程序中没有正确配置@ConfigurationProperties或@Component注释。
@ConfigurationProperties注释用于将属性映射到Java对象,而@Component注释用于将Java类标记为Spring组件。
您需要检查您的代码,确保@ConfigurationProperties注释正确地映射了属性,并且@Component注释正确地标记了类。
如果您仍然遇到问题,请提供更多的上下文和代码示例,以便我们更好地帮助您解决问题。
相关问题
Not registered via @EnableConfigurationProperties, marked as Spring component, or scanned via @ConfigurationPropertiesScan
回答: "Not registered via @EnableConfigurationProperties, marked as Spring component, or scanned via @ConfigurationPropertiesScan" 这个错误信息表示某个组件没有通过@EnableConfigurationProperties进行注册,或者没有标记为Spring组件,或者没有通过@ConfigurationPropertiesScan进行扫描。这个错误可以通过在启动类中加入@EnableConfigurationProperties注解来解决。@EnableConfigurationProperties注解的作用是让使用了@ConfigurationProperties注解的类生效。所以在启动类中加入@EnableConfigurationProperties注解即可解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [【Spring Boot采坑记】- 自定义配置之 @ConfigurationProperties 和 @EnableConfigurationProperties](https://blog.csdn.net/wy0682109523/article/details/106542913)[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^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Not registered via @EnableConfigurationProperties, marked(@ConfigurationProperties的使用)](https://blog.csdn.net/weixin_47316183/article/details/125312210)[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^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [Not registered via @EnableConfigurationProperties, marked as Spring component, or scanned via @Confi](https://blog.csdn.net/HRX98/article/details/131823871)[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^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
未通过 @EnableConfigurationProperties 注册、标记为 Spring 组件或通过 @ConfigurationPropertiesScan 扫描
未通过 @EnableConfigurationProperties 注册、标记为 Spring 组件或通过 @ConfigurationPropertiesScan 扫描的问题可以通过以下几种解决方式来解决:
1. 确保在你的配置类上使用了 @EnableConfigurationProperties 注解来注册该配置类作为一个 Spring 组件。这样 Spring 将会扫描并加载这个配置类。
2. 如果你使用的是 SpringBoot 2.2 版本及以上,可以直接使用 @ConfigurationPropertiesScan 注解开启自动扫描。这样 SpringBoot 将会自动扫描并注册所有带有 @ConfigurationProperties 注解的配置类。
3. 确保在配置类上使用了 @Component 注解,将其标记为一个 Spring 组件。这样 Spring 将会自动扫描并加载这个配置类。
请根据你的具体情况选择适合的解决方式来解决未通过 @EnableConfigurationProperties 注册、标记为 Spring 组件或通过 @ConfigurationPropertiesScan 扫描的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Not registered via @EnableConfigurationProperties or marked as Spring component](https://blog.csdn.net/li1325169021/article/details/116768787)[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_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [@EnableConfigurationProperties @ConfigurationProperties @ConfigurationPropertiesScan](https://blog.csdn.net/u013202238/article/details/107133200)[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_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文