I have a @Service
annotated class which provides core functionality which I can use in all my projects:
@Service
public class MyService {}
and another one which extends it to implement project specific stuff:
@Service
public class ExtendedMyService extends MyService {}
Now I would like to configure a bean alias to be able to use @Qualifier("MyServiceAlias")
when autowiring it using a property:
# MyService qualifier (default: myService)
myService.qualifier=extendedMyService
In XML it would look like:
<alias name="${myService.qualifier}" alias="MyServiceAlias" />
It is also discussed here, but I need to do it w/o XML, JavaConfig only. Is it possible and how to realize?
There is an open Jira for this: https://jira.spring.io/browse/SPR-6736
The workaround is to use @Bean
in @Configuration
class:
@Configuration
public class AppConfig {
@Bean(name = { "dataSource", "subsystemA-dataSource", "subsystemB-dataSource" })
public MyService myService() {}
}
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