Closed
Description
I have an outstanding SO question that I don't think is supported as a use case as of 1.2.1. Essentially, I would like to use the functionality provided by @ConditionalOnProperty
along with the type-safe @ConfigurationProperties
. Currently, Spring Boot registers the properties bean regardless of whether any of the properties listed on it exist, so it's impossible to use @ConditionalOnBean(MyConfigProps.class)
(I just get a bean with all null
fields).
I would like either a way to suppress registration of an "empty" properties bean or a condition that matches only if the bean of the specified @ConfigurationProperties
class exists.
Example:
@ConfigurationProperties(prefix = 'my.service')
class ServiceProps {
String apiKey
}
@Configuration
@ConditionalOnConfigurationProperties(ServiceProps.class)
// or @ConditionalOnBean(ServiceProps.class)
class MyServiceAutoConfig {
@Autowired
ServiceProps serviceProps
@Bean MyService myService() // ...
}