A Component required a bean of type ‘xxx.config.xxx‘ that could not be found问题解决办法
A Component required a bean of type ‘xxx.config.xxx’ that could not be found问题解决办法项目中修改了config包下的一个代码后,启动报错:Description:A Component required a bean of type 'xxx.config.xxxConfig' that could not be fou
·
A Component required a bean of type ‘xxx.config.xxx’ that could not be found问题解决办法
项目中修改了config包下的一个代码后,启动报错:
Description:
A Component required a bean of type 'xxx.config.xxxConfig' that could not be found.
Action:
Consider defining a bean of type 'xxx.config.xxxConfig' in your configuration.
原来是改代码的时候,误删掉了xxxConfig.java中class上面的注解 @Configuration
加上注解@Configuration后,报错解决。
【扩展其他情况】
报错:
Description:
A Component required a bean of type 'xxx.service.xxxService' that could not be found.
Action:
Consider defining a bean of type 'xxx.service.xxxService' in your configuration.
-
情况1:
检查Service对应的实现类,有没有加@Service
注解 -
情况2:
检查Service有没有对应的实现类(本人有次报错是因为拉远程代码时候,没有Service对应的实现类) -
情况3:
springboot应用启动的时候,bean的加载扫描失败,确保Application类扫描到你报错类所在的包(代码如下),或保证与另外的服务同级,因为是自上而下扫描加载,所以你只需要将启动类移动到包结构目录开始不一样的层级,就可以顺利启动了
@SpringBootApplication(scanBasePackages = {"com.xxx.xxx.xxx1", "com.xxx.xxx.xxx2"})
更多推荐
已为社区贡献16条内容
所有评论(0)