美文网首页java编程笔记
Could not autowire. No beans of

Could not autowire. No beans of

作者: 爱宝宝n | 来源:发表于2019-04-24 19:46 被阅读4次

    一、前言
    今天在用Idea新建项目开发的过程中又遇到这个错误:
    Could not autowire. No beans of 'xxxx' type found;
    虽然不影响项目运行,但是有强迫症的人看着就是难受,而且红色的错误提示在程序猿眼中是零容忍的。
    下面想分享下一般遇到这个问题的原因和解决方法。

    二、原因和解决方法
    1.Spring auto scan配置,在编辑情况下,无法找不到对应的bean,于是提示找不到对应bean的错误。常见于mybatis的mapper;
    如下图:


    错误信息.png

    解决方法:

    File->Settings->Editor->Inspections->Spring->Spring Core->Code->Autowiring for Bean Class 把Severity的Error改为Warning


    更改idea配置.png

    2.引入其他类或接口的时候出现重复命名
    解决方法:把名称更改成不一样的就可以了


    重复名.png

    相关文章

      网友评论

        本文标题:Could not autowire. No beans of

        本文链接:https://www.haomeiwen.com/subject/ofvwgqtx.html