I am using @ComponentScan
and @Component
to define my spring beans. What I would like is to declare one of these beans to be autowire-candidate=false
.
This could be done with this attribute in xml. Isn't there the equivalent in annotations?
The reason I want this is because I have 2 implementations of the same interface and I don't want to use @Qualifier
.
EDIT: Using @Primary is a valid work-around, but autowire-candidate seems to me like a useful feature with its own semantics.
Thanks
Since Spring 5.1 , you can configure autowire-candidate
in @Bean
through autowireCandidate
attribute:
@Bean(autowireCandidate = false)
public FooBean foo() {
return newFooBean();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With