bean的类名为SecurityProperties 导致SpringBoot启动失败

 

现象:

当 Bean的类的类名为 SecurityProperties时,启动会报错:

***************************
APPLICATION FAILED TO START
***************************

Description:

Field securityProperties in org.xxx类 required a bean of type 'org.xxx.SecurityProperties' that could not be found.


Action:

Consider defining a bean of type 'org.zen.security.core.properties.SecurityProperties' in your configuration.

 

不管是通过 @Component 还是 @Configuration 还是其他方式注册的,如果该Bean被其他类 注入,则在启动时报上述错误。

 

分析:

可能是因为SpringBoot中已经有个 名为 SecurityProperties 的类(org.springframework.boot.autoconfigure.security.SecurityProperties)了,造成了冲突。

 

解决:

类修改为其他的名字就好了。

posted on 2018-02-18 15:44  HB1  阅读(1134)  评论(0)    收藏  举报

导航