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. python什么时候加self,什么时候不加self

    1.self是什么,一般都说指对象本身,这样说了没了用,说了后还是很难懂,因为这样说了后,仍然完全搞不清楚,什么时候变量前需要加self,什么时候不需要加self. 造成很多人,已经怕了self,不停 ...

  2. 删除JS 对象属性(元素)

    var a={"id":1,"name":"danlis"}; //添加属性 a.age=18; console.log(a); //结果: ...

  3. php四个常用类封装

    这4个类分别是Mysql类. 分页类.缩略图类.上传类. Mysql类 <?php /** * Mysql类 */ class Mysql{ private static $link = nul ...

  4. 机器人学 —— 机器人感知(Location)

    终于完成了Robotic SLAM 所有的内容了.说实话,课程的内容比较一般,但是作业还是挺有挑战性的.最后一章的内容是 Location. Location 是 Mapping 的逆过程.在给定ma ...

  5. thinkcmf 忘记后台登陆密码的解决办法

    thinkcmf 忘记密码 或者 密码错误 如何修改后台登陆密码? 直接在后台登陆控制器里输入 dump(cmf_password('123456')); 参考文件路径 app\admin\contr ...

  6. flask使用pymysql连接MySQL,生成xls文件并下载到本地

    版本一:将MySQL数据写入到excel(xsl)文件并下载到默认文件夹(一般问电脑的下载文件夹里面),并显示特效到前端页面. flask框架连接MySQL,我们使用pymsql这个工具,如下操作: ...

  7. Python Solve UnicodeEncodeError 'gbk' / 'ascii' / 'utf8' codec can't encode character '\x??' in position ? 解决有关Python编码的错误

    在Python中,处理中文字符一直是很令人头痛的问题,一言不合就乱码,而且引起乱码的原因也不尽相同,有时候是python本身默认的编码器设置的不对,有时候是使用的IDE的解码器不对,还有的时候是终端t ...

  8. 在浏览器上使用 react

    unpkg material-ui mobx react-router-dom 所有包为开发环境使用 <!DOCTYPE html> <html lang="en" ...

  9. Access无法启动应用程序,工作组信息文件丢失,或是已被其他用户已独占方式打开

    使用SQL Server导入有密码的Access数据库内容,连接时出现错误提示: Access无法启动应用程序,工作组信息文件丢失,或是已被其他用户已独占方式打开 参考百度信息,可以点上图中的高级,在 ...

  10. WPS生成文章目录

    WPS生成文章目录 1.引用–>插入目录...即可!