My Spring Boot application doesn't seem to be recognising lists in my configuration file (application.yml). Below is roughly what I'm trying to do.
Java Code:
@Autowired
private Environment environment;
public class Config{
public Config(){
}
public List<String> getDateFields(){
return environment.getProperty("dates.fields", List.class);
}
}
application.yml:
dates:
fields:
- date
- creationDate
getDateFields returns null above. However, if I use the following...
application.yml:
dates:
fields: creationDate
...it works fine and returns it as a list (albeit a single valued one). Why can't I get the list from my application.yml file? I tried checking whether environment even contained dates.fields, and environment.containsProperty("dates.fields") returns false when using the list version.