zoukankan      html  css  js  c++  java
  • 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了。

  • 相关阅读:
    EncodeLDPC校验矩阵H的高斯变换
    Linuxubuntu学习(一)
    tcp通信
    HTTP协议,超文本传输协议
    局部变量成员变量
    线程
    正则表达式
    面向对象
    String类
    Object类
  • 原文地址:https://www.cnblogs.com/yidiandhappy/p/9009477.html
Copyright © 2011-2022 走看看