出现Not registered via @EnableConfigurationProperties or marked as Spring component

解决方案一:在pom.xml添加

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-configuration-processor</artifactId>
      <optional>true</optional>
    </dependency>

在解决方案一还不能解决的时候,添加了解决方案一的代码后,在配置类上添加

@EnableConfigurationProperties(HelloServiceProperties.class)
//括号内填出现问题的类名

 

  • 6
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
回答: "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 ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值