把启动类改成@SpringBootApplication(scanBasePackages = {"service","dao","config”})

 

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

个人猜测与扫描的包有关,但这只是笼统的的写法。不一定会解决问题,但会让项目跑起来不报错。

解决办法,其实还是与包有关,可直接改为具体的或顶级根包

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

@SpringBootApplication(scanBasePackages = {"com.tianjian.web"})

或改为@SpringBootApplication(scanBasePackages ={"com.tianjian.web.service","com.tianjian.web.dao","com.tianjian.web.config”,"com.tianjian.web.propertytschedules.controller"})

相关文章: