Reputation: 8189
Is it possible to select what service implementation to use via a command line option or value in the application.properties files (ideally with a default). Does that solution works with @EnableAutoConfiguration
?
My use case is the following: I have an application that has 3 service implementations, and depending on the environment I would like to select one or the other.
Currently only one of the implementations is marked with @Service
, as otherwise @EnableAutoConfiguration
does not work.
Upvotes: 0
Views: 313
Reputation: 58094
Maybe you can use Spring profiles. Mark each @Bean
implementation with @Profile("...")
and then start your app with spring.profiles.active=...
to select the beans you need.
Upvotes: 2