Skip to content

RabbitTemplate dependency of autoconfigured RabbitMessagingTemplate with custom RabbitTemplate #2011

@bijukunjummen

Description

@bijukunjummen

RabbitMessagingTemplate has a dependency on RabbitTemplate, now if I were to define my custom RabbitTemplate, this autoconfiguration fails as then there are two RabbitTemplates available. Can you please suggest a good workaround, this is the exception:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitMessagingTemplate' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$MessagingTemplateConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.amqp.rabbit.core.RabbitTemplate]: : No qualifying bean of type [org.springframework.amqp.rabbit.core.RabbitTemplate] is defined: expected single matching bean but found 2: amqpTemplate,rubeExchangeTemplate; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.amqp.rabbit.core.RabbitTemplate] is defined: expected single matching bean but found 2: amqpTemplate,rubeExchangeTemplate
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:752)

Temporarily I have worked around this by defining my own RabbitMessageTemplate which prevents the autoconfigured one from being defined also.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions