Reputation: 979
I have a yaml file like this one
framework:
generalConfiguration:
cassandra:
fe:
seeds:
- fire201
- fire202
dc: DC
And a bean
public class ConfigurationBean{
private Map<String, Object> generalConfiguration;
public Map<String, Object> getGeneralConfiguration() {
return generalConfiguration;
}
public void setGeneralConfiguration(Map<String, Object> generalConfiguration) {
this.generalConfiguration = generalConfiguration;
}
A bean factory methods
@Bean(name = "configurationDataHolder")
@ConfigurationProperties(prefix = "framework")
public ConfigurationBean configurationBean(){
return new ConfigurationBean();
}
My problem is that spring boot populates the generalConfiguration Map where : fe is a Map with keys
seeds
dc
dc is a String value entry. and seeds is a map like this one:
0 -> fire201
1 -> fire202
I would expect seeds to be populated as a List.
Any idea how to do that?
Upvotes: 0
Views: 724
Reputation: 33151
Your generalConfiguration
is using a raw type for the value so you're not giving any clue to the framework as what it is supposed to do with it. When you look at your configuration, it may be obvious to you but we process the configuration by browsing relationships one by one and taking the best possible options.
Your Object
does not give any hint. Mixing simple values and maps in the same structure is also a smell.
Upvotes: 1