关于Could not autowire. No beans of 'xxxx' type found. 解决方法之一

发布时间 2023-03-23 19:49:58作者: 昼夜山

关于Could not autowire. No beans of 'xxxx' type found. 解决方法之一

原因:启动类与配置类是在一个包下 但是不同包 而且配置类也不是子包 启动类没扫描到配置类

这时候有两种解决方案
第一种需要在Springboot启动类上添加@ComponentScan(basePackages = {"包名"})

第二种直接将启动类挪到外面的父包下