Reading a Map from properties file and load with spring annotation @Value
java, spring
Solution
application.properties:
property.map={first:value, second:value}
then in Java code you can:
@Value("#{${property.map}}")
Map<String, String> map;
Problem
I have a list of (key/value) need to be populated to a map on a spring bean: ``` dmin.details.fieldsMap=name,Abdullah,\ street,Zayed,\ phone,+201020102010 ``` It's working fine with me using a list as below: property: dmin.details.fields=Abdullah,Zayed,+201020102010 Calling: ``` @Value("#{'${dmin.details.fields}'.split(',')}") private List<String> fields; ``` Could anyone advise if this is doable in Spring?