欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

A component required a bean of type ‘XXX‘ that could not be found 解决办法

程序员文章站 2022-06-24 20:34:15
...

springboot应用启动的时候,bean的加载扫描失败,错误信息如下A component required a bean of type 'XXX' that could not be found.

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

Description:

A component required a bean of type 'com.littlefox.cloud.api.sequence.remote.RemoteSequenceService' that could not be found.

Action:

Consider defining a bean of type 'com.littlefox.cloud.api.sequence.remote.RemoteSequenceService' in your configuration.

场景是这样的,我依赖了我另外一个服务用来生成主键ID,但是这两个项目包结构不一样 com.littlefox.generic.GenericApplication

解决办法
GenericApplication类移动到com.littlefox下,保证与另外的服务同级,因为是自上而下扫描加载,所以你只需要将启动类移动到包结构目录开始不一样的层级即可,在我这里最后为 com.littlefox.GenerricApplication 就可以顺利启动了