Skip to content

Autowiring by name not working in 3.2.0? #38536

@anogueiraFlywire

Description

@anogueiraFlywire

Hello team,
We've tried upgrading to version 3.2.0 of Spring Boot and we came across what we think might be a bug.
With this new version, Autowiring by name doesn't seen to be working, and it's forcing us to include a @qualifier(name) tag whenever we have multiple beans of the same type. Is this behaviour intended and we missed it from the docs?

Example:

We have multiple Queue and TopicExchange defined with different names, like

@Bean
   Queue activityQueue(@Value("${amqp.activity.queue}") String queueName) {
       return new Queue(queueName);
   }

And we used to inject it with:

@Bean
   Binding rabbitActivityBinding(Queue activityQueue, TopicExchange activityExchange) {
       return BindingBuilder.bind(activityQueue)
           .to(activityExchange).with(ACTIVITY_POSTED_ROUTING_KEY);
   }
This used to find the right beans and inject them properly, but now it's complaining that it finds 9 instances and forces us to add a @Qualifier. This looks like a major change to Spring behaviour

A similar example happened with @PathVariable:
     @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseStatus(HttpStatus.OK)
    public GetPaymentResponse getPayment(@PathVariable String id)

Is now forcing us to include @PathVariable("id")

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions