Field amqpTemplate in * required a single bean, but 3 were found:

Spring Boot 启动的时候报的错

使用Spring Boot1.5.8版本。

系统中使用了amqp组件,同事手写了两个RouteKey的RabbitTamplate的模板,项目中*类中@Autowired了RabbitTamplate。

然后就报了这个错,意思是找到了3个模板,不知道自动注入哪一个,建议:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

我们希望注入的是Spring Boot Auto出来的,但是我们只能使用@Qualifier(在用到的地方添加,@Qualifier(name="")指定名字)注解,因为@Primary(在定义的Bean上添加,为优先使用),但是又不可能使用原生的,所以自己定义一个。

在使用的时候使用@Qualifier指定一下自己声明的就OK了。

Field amqpTemplate in * required a single bean, but 3 were found:的更多相关文章

  1. 【记录】Field required a single bean, but 2 were found:

    重构遇到个小问题,记录下: 错误信息: *************************** APPLICATION FAILED TO START ************************ ...

  2. Field in required a single bean, but 2 were found:

    我在其他类注入的时候出现以下错误 @Autowired NodeAgentService nodeAgentService; 异常 Description: Field mibService in c ...

  3. Field baseMapper in com.baomidou.mybatisplus.extension.service.impl.ServiceImpl required a single bean, but xx were found:

    在学习使用 mybatis-plus 时,遇到一个奇怪的异常 如 代码一: 代码一: Error starting ApplicationContext. To display the conditi ...

  4. @Autowired注解 --required a single bean, but 2 were found出现的原因以及解决方法

    @Autowired注解是spring用来支持依赖注入的核心利器之一,但是我们或多或少都会遇到required a single bean, but 2 were found(2可能是其他数字)的问题 ...

  5. Parameter 0 of method sqlSessionTemplate in org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration required a single bean, but 2 were found:

    Parameter 0 of method orderSqlSessionFactory in com.config.MultipleDBConfig required a single bean, ...

  6. springboot多数据源启动报错:required a single bean, but 6 were found:

    技术群: 816227112 参考:https://stackoverflow.com/questions/43455869/could-not-autowire-there-is-more-than ...

  7. Spring多个数据源问题:DataSourceAutoConfiguration required a single bean, but * were found

    原因: @EnableAutoConfiguration 这个注解会把配置文件号中的数据源全部都自动注入,不会默认注入一个,当使用其他数据源时再调用另外的数据源. 解决方法: 1.注释掉这个注解 2. ...

  8. springboot:@ConditionalOnProperty根据不同时机注入不同实现的bean

    一.引言 在开发中经常会碰到这样的情形,一个接口会有不同的实现,但在开发中都是基于接口的注入,那么怎么根据不同的需求注入不同的类型就是一个值得考虑的问题.在注入属性时常用的两个注解是@Autowire ...

  9. Spring boot使用Redis时,报错,有redisTemplate和stringRedisTemplate两个bean?

    Error starting ApplicationContext. To display the auto-configuration report re-run your application ...

随机推荐

  1. [2]朝花夕拾-JAVA注解、PHP注解?

    一.Java注解概述 注解,也被称为元数据,为我们在代码中添加信息提供了一种形式化的方法,是我们可以在稍后某个时刻非常方便地使用这些数据. 注解在一定程度上是把元数据与源代码文件结合在一起,而不是保存 ...

  2. Cxf weblogic 报错: when resolving method "javax.xml.bind.JAXBElement

    Cxf weblogic 报错: when resolving method "javax.xml.bind.JAXBElement ============================ ...

  3. Spring框架介绍及使用

    Spring框架—控制反转(IOC)1 Spring框架概述1.1 什么是Spring1.2 Spring的优点1.3 Spring的体系结构2 入门案例:(IoC)2.1导入jar包2.2目标类2. ...

  4. [原]Jenkins(十八) jenkins再出发之jenkins 内置变量

    1.选择一个project的config选项: 2.选择build选项卡,选择Execute Windows batch command 3.会出现一个内置变量的list 连接按钮: 4.list表内 ...

  5. selenium 操作过程中,元素标红高亮的两种实现方式

    在使用selenium时,动作元素标红高亮,在定位问题时相当好用,有以下二种方法可以实现 一.使用js将元素属性修改 这也是网上大部分的实现方式,但有时候会有点小问题,代码如下: 只写其实某一段函数 ...

  6. win7 蓝屏信息获取和处理

    一.先说电脑蓝屏原因和解决方法: 1.驱动不对,驱动和硬件不兼容出现的问题,这个直接卸载软件或者重装驱动. 2.内存条有问题或者内存损坏:这个内存条很可能是没插紧,内存损坏的话,换个内存条. 3.病毒 ...

  7. MySQL中kill掉所有表的进程

    同事打电话告诉我用户数据库挂掉了. 我起床看一下进程列表. mysql>show processlist; 出来哗啦啦好几屏幕的, 没有一千也有几百条, 查询语句把表锁住了, 赶紧找出第一个Lo ...

  8. loadrunner笔记(二):飞机订票系统--客户信息注册

    (一)  几个重要概念说明 集合点:同步虚拟用户,以便同一时间执行任务. 事务:事务是指服务器响应用户请求所用的时间,当然它可以衡量某个操作,如登录所需要的时间,也可以衡量一系列的操作所用的时间,如从 ...

  9. jquery 倒计时

    今天让我公司前端大神,李杨哥,给做了一个jquery倒计时功能  很牛逼 看下面的效果图 这个倒计时是需要传值的,看效果代码讲解  百度云盘 ,压缩包永久有效  链接: https://pan.bai ...

  10. NodePort 只能在node节点上访问,外部无法访问

    创建了一个NodePort类型的jenkins service,node port 30000,node节点ip为192.168.56.101, 在node节点上通过浏览器能正常访问http://19 ...