nrich-spring-boot
is a module containing add-ons on Spring Boot framework. Currently, no additional configuration is needed, just adding the module as dependency is enough. This module contains
only ConditionalOnPropertyNotEmpty
annotation (for now). It is used to register beans only when property is not empty, it supports strings, list of strings and lists of objects.
@Configuration(proxyBeanMethods = false)
public class ApplicationConfiguration {
@ConditionalOnPropertyNotEmpty("example.bean.condition.list")
@Bean
public ExampleBean exampleBean() {
return new ExampleBean();
}
}
For usage, it is enough to add annotation to bean that should only be registered when property is not empty. In former example bean ExampleBean
will only be registered when property example.bean.condition.list
is not empty.