关于报错Consider defining a bean of type 的解决

编程知识 更新时间:2023-05-02 05:24:46

关于报错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);
    }
}

更多推荐

关于报错Consider defining a bean of type 的解决

本文发布于:2023-04-26 05:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/1f8fc3575c413860e573b41ee104cc01.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:报错   defining   type   bean

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 104380文章数
  • 26212阅读数
  • 0评论数