Using an interface with two bean implementations. One implementation has a conditional.
I want them to be mutually exclusive, resulting in a single bean implementing interface.
Tried the following that results in missing bean:
interface BaseService {}
@Service
@ConditionalOnProperty(...)
class ConditionalService implements BaseService{}
class FallbackService implements BaseService {}
@Configuration
class MyConfiguration {
@Bean
@ConditionalOnMissingBean
public BaseService fallbackService() {
return new FallbackService();
}
}
Rejected github issue and sample repo: https://github.com/spring-projects/spring-boot/issues/24227