
关于报错Consider defining a bean of type 的解决
关于报错Consider defining a bean of type 的解决
运行SpringBoot的时候报如下错Consider defining a bean of type ‘com.google.code.kaptcha.Producer’ in your configuration.
报错原因为配置中找不到一个指定自动注入类型的bean。 那么我们要从collecter层开始查找,点击service层,看service实现类是否加上@Service或者@Component,检查service实现类是否有implements service。如果这些都没有问题:
我们来看@SpringBootApplication,点过去。可以看到有个@ComponentScan,ComponentScan做的事情就是告诉Spring从哪里找到bean
那可以直接在@SpringBootApplication加上
@SpringBootApplication @ComponentScan(basePackages ={value = {"com.google.code", "aaa", "bbb" }) public class OfficialSystemApplication { public static void main(String[] args) { SpringApplication.run(xxxApplication.class,args); } }👁️ 阅读量:0
© 版权声明:本文《关于报错Consider defining a bean of type 的解决》内容均为本站精心整理或网友自愿分享,如需转载请注明原文出处:https://www.zastudy.cn/wen/1686556907a291275.html。