Consider defining a bean of type ‘xxx‘ in your configuration

一、类没有注册(最常见)

//注册常用注解
@Component
@Service
@Controller
@Repository

二、使用了@ComponentScan

@ComponentScan注解使用后,springboot只会扫描其中包含的类,如果提示某个类找不到,看下是不是写漏了

@ComponentScan({
    
    "com.cs.a", "com.cs.b", "com.cs.c", "com.cs.d"})

三、项目之前是好的,突然提示某个类不存在

使用maven重新编译,先clean再install

猜你喜欢

转载自blog.csdn.net/LuoHuaX/article/details/127222651