I'm working on a Spring Boot project where I want an array of strings to be defined in my application.yml
file. I want to use Spring to inject this array into a variable for use inside of one of my classes as below:
@Component
Class foo {
@Value("${properties.ymlArray}")
private ArrayList<String> fooArray;
@Value("${properties.ymlArray[1]}")
private String itemFromFooArray;
}
My YML file is as follows:
properties:
ymlArray: [item1, item2, item3]
In the above example itemFromFooArray
populates correctly, getting an item from the array, but I have not found the appropriate way to inject the entire array into a variable.
Any ideas? Thanks!
[https://stackoverflow.com/questions/26699385/spring-boot-yaml-configuration-for-a-list-of-strings](https://stackoverflow.com/questions/26699385/spring-boot-yaml-configuration-for-a-list-of-strings) – peterzinho16 Jan 26 '18 at 19:49