springcloud 自己挖坑 @ConfigurationProperties不生效

***************************
APPLICATION FAILED TO START
***************************
Field securityProperties in xxx required a bean of type 'com.xxx.xx.core.xxx.XXXProperties' that could not be found.
Action:

Consider defining a bean of type 'com.xxx..XXXProperties' in your configuration.

 

自己做一个springcloud的时候遇到了

@ConfigurationProperties不生效,然后报错如上

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

百度说需要加这段,实际pom里面已存在这个,找了我半夜也没找到为什么另一个工程行,这个就不行

早上没有目的的百度找了找几个答案,灵光乍现

from:https://blog.csdn.net/qq_30725371/article/details/80356156

 

我仔细想想,应该是我启动类移动了地方导致的,因为我引用的propertie 是在base目录下,全路径为com.x.base.XXXProperties,

我的启动类原先在com.x包下,被我移至com.x.zzz下(com.x.zzz.XXXApplication),启动就是报错,很郁闷

后来移回至com.x包下,竟然可行了,看来 ComponentScan 如果默认则扫描范围是当前包路径向下的所有路径

 

转载于:https://www.cnblogs.com/tiaowen/p/11058064.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值