Is it possible to leverage Spring-Boot's YAML configuration outside a spring-boot application? i.e Can we use just the YAML config feature adding the spring-boot dependency?
My usecase is a small utility project which needs configuration and YAML approach is apt. If I wire this to the master project (which is a Spring-Boot app), all is fine. But if I want to test this utility project separately (simple java-app) it doesn't get the configuration wired. Any thoughts? may be I'm missing something basic here.
Sample code snippet below. The below package is part of the component-scan.
@Component
@ConfigurationProperties(prefix="my.profile")
public class TestConfig {
private List<String> items;
public List<String> getItems() {
return items;
}
public void setItems(List<String> items) {
this.items = items;
}
}
YAML Config
my:
profile:
items:
- item1
- item2
@ConfigurationProperties
are 2 separate things. Yaml support is available in Spring itself,@ConfigurationProperties
is a feature of spring boot. – M. DeinumYamlPropertiesFactoryBean
to have a yaml file read and to be available as properties. It is also available as of Spring 4.1 so it wouldn't work on earlier versions. – M. Deinum