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 如果默认则扫描范围是当前包路径向下的所有路径

猜你喜欢

转载自www.cnblogs.com/tiaowen/p/11058064.html
今日推荐