My property file has a content as follows
config.entry[0]=X-FRAME-OPTIONS,SAMEORIGIN
config.entry[1]=Content-Security-Policy,Frame-Ancestors 'self'
I want this to be loaded to a config class where i can have the comma seperated values loaded as Key,Value pairs in a collection. How can this be achieved using @ConfigurationProperties in Spring 3 ?
Entries = config.getEntry() should give me a collection so that I can iterate and get the list of name value pairs defined in the property file
for(Entry<String,String> index : config.getEntry().entryset()) {
index.getKey(); // Should Give - X-FRAME-OPTIONS
index.getValue(); // Should Give - SAMEORIGIN
}
How should i define my Config class that will be autowired with the values from the properties file in this way ?
the following implementation, throws Spring exception "Cannot convert value of type [java.lang.String] to required type [java.util.Map]" for property 'entry[0]': no matching editors or conversion strategy found]
@Component
@ConfigurationProperties("config")
public class MyConfiguration {
private Map<String,Map<String,String>> entry = new LinkedHashMap<String,Map<String,String>>();
//getter for entry
//setter for entry
}