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

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

Error reported when Spring Boot starts

Use Spring Boot version 1.5.8.

The amqp component is used in the system, and my colleague wrote two RouteKey RabbitTamplate templates, and @Autowired RabbitTamplate in the * class in the project.

Then I reported this error, which means that 3 templates were found, and I don't know which one to inject automatically. It is recommended:

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

What we want to inject is Spring Boot Auto, but we can only use @Qualifier (add it where it is used, @Qualifier(name="") specifies the name) annotation, because @Primary (add it on the defined Bean, For priority use), but it is impossible to use the native one, so define one yourself.

It is OK to use @Qualifier to specify what you declare when you use it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325858434&siteId=291194637