场景

SpringBoot项目运行时提示:

SpringBoot 报错Field XXX required a bean of type XXX that could not be found._springboot

解决

首先查看service下是否有@Service注解

SpringBoot 报错Field XXX required a bean of type XXX that could not be found._springboot_02

这里有。

然后找到启动类

修改前:

SpringBoot 报错Field XXX required a bean of type XXX that could not be found._springboot_03

修改后:

SpringBoot 报错Field XXX required a bean of type XXX that could not be found._springboot_04

添加:

@SpringBootApplication(scanBasePackages = {"service","dao","config"})