【自定义 starter 报错 bean 没有注入service 或者 其他东西】
今天自定义了以下 springboot-starter ,出现了一些小问题
## 在准备好场景启动器 starter 并且引入了 autoconfiguratuion 包后,一切环境准备就绪 运行测试包时报错了以下内容:
Field helloService in com.atguigu.boot.controller.HelloController required a bean of type 'com.atguigu.hello.service.HelloService' that could not be found.
我开始以为是没有在 自定义的 webconfiguration 包内相关service 没有@Bean 注入容器,后来仔细研究后 是发现了自动装配出现的问题,就是没有引入容器中,然后我就选择在 测试包的主程序上加入
@ComponentScan({"(写自己需要扫描的包)","(配置文件的包)"})
将其扫描后项目成功运行解决问题