If @Qualifier
supported SpEL it would make configuration driven selection of beans much easier.
interface Provider {}
@Component @Qualifier("file") class FileProvider implements Provider {}
@Component @Qualifier("db") class DbProvider implements Provider {}
class Service {
@Autowired @Qualifier("${app.provider}") Provider;
}
Saves me from creating config class with multiple @ConditionalOnProprety
beans.
Comment From: mwisnicki
Forgot to mention this is for the case where one need both instances to exist in the app.
Otherwise you can put @Conditional
on implementation classes.
Comment From: snicoll
Thanks for the suggestion. This is a duplicate of https://github.com/spring-projects/spring-framework/issues/27283