更新项目之后IDEA突然出现了这样的报错信息。显示Could not autowire. There is more than one bean of 'xxx' type。这个错误的意思是xxx类型有不止一个bean,但是这个错误不会影响项目运行,相当于一个warning。



导致这个错误的原因通常是注入的类型有其他的实现类,所以IDEA提示注入的时候会冲突。比如我的项目出现这个错误的原因是项目中新增了一个定制的插件,这个插件里重写了这个类。

因此出现这个问题的时候可以有两种办法解决。

1.给不同的实现标注名字

使用Qulifier注解标注

@Autowired
@Qualifier(name = 'testService1')
private TestService testService;

2.使用@Primary

@Component
@Primary
public class TestService{}

参考文章

  1. StackOverFlow: Could not autowire, there is more than one bean error

  2. CSDN: spring @Primary-在spring中的使用

解决IDEA报错Could not autowire. There is more than one bean of 'xxx' type的更多相关文章

  1. Idea使用记录--添加Problems&&解决Autowired报错could not autowire

    今天在使用Idea的时候,发现Idea在整个每次找到错误代码非常不方便(Idea如果类中有错误,没有打开过类并不会提示,比如构建工程后缺少jar包问题).我想快速看到工程哪里出问题类似于eclipse ...

  2. 解决springmvc报错,java.lang.IllegalArgumentException:No converter found for return value of type: class .......

    1.背景 最近在自学java中的三大框架 ssm,在 springmvc 与 mybatis 整合过程中用到 json 数据交互.因为看的视频的是比较早的嘛,一些配置.jar包什么的,要么跟 jdk ...

  3. [转]解决Maven报错"Plugin execution not covered by lifecycle configuration"

    [转]解决Maven报错"Plugin execution not covered by lifecycle configuration" 导入Myabtis源码后,POM文件会报 ...

  4. 解决MySQL报错ERROR 2002 (HY000)【转】

    今天在为新的业务线搭架数据库后,在启动的时候报错 root@qsbilldatahis-db01:/usr/local/mysql/bin# ./mysql ERROR 2002 (HY000): C ...

  5. vue解决启动报错cjs loader.js Error: Cannot find module '../config'问题

    vue解决启动报错cjs loader.js Error: Cannot find module '../config'问题 今天下载了一个开源项目一直运行不了,折腾了半天才找到问题所在,config ...

  6. 解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办

    解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办 问题是出现在了PHP.INI上面了 ,原 ...

  7. 解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'informat

    解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'informat ...

  8. eclips中maven解决jsp报错的问题

    加入如下的pom依赖: <!-- 解决jsp报错的依赖包第一个 --> <dependency> <groupId>javax.servlet</groupI ...

  9. 不修改系统日期和时间格式,解决Delphi报错提示 '****-**-**'is not a valid date and time

    假如操作系统的日期格式不是yyyy-MM-dd格式,而是用strtodate('2014-10-01')) 来转换的话,程序会提示爆粗 '****-**-**'is not a valid date ...

随机推荐

  1. Handler注意事项

    一. Handler与Thread的区别. Handler与调用者处于同一线程,如果Handler里面做耗时的动作,调用者线程会阻塞.Android UI操作不是线程安全的,并且这些操作必须在UI线程 ...

  2. 深度学习之NLP获取词向量

    1.代码 def clean_text(text, remove_stopwords=False): """ 数据清洗 """ text = ...

  3. 一百零九:CMS系统之前端根据不同权限渲染不同菜单

    给用户绑定为开发者 个人信息中渲染角色和权限 {% extends 'cms/cms_base.html' %} {% block title %} 个人信息{% endblock %} {% blo ...

  4. Oracle动态执行脚本创建序号

    -----------------------动态创建序列的脚本--------------------------- declare type num_list ) ); -- 老师表.学生表 xz ...

  5. 转 - JS 中 call 和 apply 以及 bind 的区别

    转自 https://blog.csdn.net/wyyandyou_6/article/details/81488103

  6. 二、Linux用户身份

    0.介绍: 管理员UID为0:系统的管理员用户. 系统用户UID为1-999: Linux系统为了避免因某个服务程序出现漏洞而被黑客提权至整台服务器,默认服务程序会有独立的系统用户负责运行,进而有效控 ...

  7. Python smtplib发邮件

    常用邮箱SMTP.POP3域名及其端口号 发送普通文本内容的邮件 import smtplib from email.header import Header from email.mime.text ...

  8. SpringBoot项目在IDEA中以jar方式部署

    1.在pom.xml下添加如下插件 这个插件可以在项目打包成jar包后,通过java -jar运行 <build> <plugins> <plugin> <g ...

  9. 【转帖】 解开龙芯与mips4000的关系

    -- 苏联给的套件,我们只要把电子管插上就好. -- 千万次机器,不晓得来源 DJS-130系列,16位小型机,仿造美国NOVA DJS-180系列,超级小型机,仿造美国DEC VAX, 能跑DEC的 ...

  10. python -- TypeError: 'module' object is not callable

    文件: 代码: import pprintmessge = 'It was a bringht cold day in April,and the clocks were striking thrir ...