Field amqpTemplate in * required a single bean, but 3 were found:
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:的更多相关文章
- 【记录】Field required a single bean, but 2 were found:
重构遇到个小问题,记录下: 错误信息: *************************** APPLICATION FAILED TO START ************************ ...
- Field in required a single bean, but 2 were found:
我在其他类注入的时候出现以下错误 @Autowired NodeAgentService nodeAgentService; 异常 Description: Field mibService in c ...
- 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 ...
- @Autowired注解 --required a single bean, but 2 were found出现的原因以及解决方法
@Autowired注解是spring用来支持依赖注入的核心利器之一,但是我们或多或少都会遇到required a single bean, but 2 were found(2可能是其他数字)的问题 ...
- 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, ...
- springboot多数据源启动报错:required a single bean, but 6 were found:
技术群: 816227112 参考:https://stackoverflow.com/questions/43455869/could-not-autowire-there-is-more-than ...
- Spring多个数据源问题:DataSourceAutoConfiguration required a single bean, but * were found
原因: @EnableAutoConfiguration 这个注解会把配置文件号中的数据源全部都自动注入,不会默认注入一个,当使用其他数据源时再调用另外的数据源. 解决方法: 1.注释掉这个注解 2. ...
- springboot:@ConditionalOnProperty根据不同时机注入不同实现的bean
一.引言 在开发中经常会碰到这样的情形,一个接口会有不同的实现,但在开发中都是基于接口的注入,那么怎么根据不同的需求注入不同的类型就是一个值得考虑的问题.在注入属性时常用的两个注解是@Autowire ...
- Spring boot使用Redis时,报错,有redisTemplate和stringRedisTemplate两个bean?
Error starting ApplicationContext. To display the auto-configuration report re-run your application ...
随机推荐
- linux可执行文件添加到PATH环境变量的方法
linux命令行下面执行某个命令的时候,首先保证该命令是否存在,若存在,但输入命令的时候若仍提示:command not found 这个时候就的查看PATH环境变量的设置了,当前命令是否存在于PAT ...
- ajax跨域,这应该是最全的解决方案了
前言 从刚接触前端开发起,跨域这个词就一直以很高的频率在身边重复出现,一直到现在,已经调试过N个跨域相关的问题了,16年时也整理过一篇相关文章,但是感觉还是差了点什么,于是现在重新梳理了一下. 个人见 ...
- 【Zookeeper系列】ZooKeeper伸缩性(转)
原文地址:https://www.cnblogs.com/sunddenly/p/4143306.html 一.ZooKeeper中Observer 1.1 ZooKeeper角色 经过前面的介绍,我 ...
- 11.1 vue(2)
2018-11-1 19:41:00 2018年倒数第二个月! 越努力越幸运!!!永远不要高估自己! python视频块看完了!还有30天吧就结束了! 今天老师讲的vue 主要是看官网文档 贴上连接 ...
- select 和epoll模型区别
1.select 和epoll模型区别 1.1.网络IO模型概述 通常来说,网络IO可以抽象成用户态和内核态之间的数据交换.一次网络数据读取操作(read),可以拆分成两个步骤:1)网卡驱动等待数据准 ...
- idea遇到的坑
(1)在main方法中启动报错: 或 经检查是pom.xml文件依赖的问题,解决方法1.将如下截图的<scope>去掉就好了 解决方法2:scope不删掉,在下面这里执行run: (2)如 ...
- JS实现表格使用上下左右键聚集
//调用:new tabTableInput("tblGrid","text"); var tabTableInput = function (tableId, ...
- [daily][mathematica][fcitx] mathematica 无法输入中文的问题
mathematica无法输入中文, 我的输入法使用 fcitx 于是我给fcitx的作者提了issue https://github.com/fcitx/fcitx/issues/372 数日之后, ...
- Win7 搭建Linux开发环境
Vargant Vagrant 是一个基于 Ruby 的工具,用于创建和部署虚拟化开发环境.它使用 Oracle 的开源 VirtualBox 虚拟化系统,使用 Chef 创建自动化虚拟环境. 功能特 ...
- c++代码检测工具
cppcheck是一款静态代码检查工具,可以检查如内存泄漏等代码错误,使用起来比较简单,即提供GUI界面操作,也可以与VS开发工具结合使用. 1.安装 一般会提供免安装版,安装完成后将cppcheck ...