Reputation: 33
I was able to use java Spring annotation to inject key values pair into the hashmap as follows
validationError.properties file
errorcode.map={\
"default.labOrder.oneservice": "AAAAAA", \
"default.labOrder.patient.firstName": "BBBBB", \
}
I able to use the following code to inject the values into my hashmap as follows
@Value("#{${errorcode.map}}") private Map<String, String> errorNumberMap;
However if I have a property file with the following values
errorcode.map={\
"LAB": "AAAAAA, BBBB, CCCC", \
"ECP": "AAAAAA, BBBB, CCCC", \
}
and a map Hashmap<AccessType, List> preserveMap = new HashMap() where AccessType is an enum. Does spring has any annotation that will populate my preserveMap value?
Thanks!
Upvotes: 0
Views: 761
Reputation: 1573
Mapping properties directly into bean fields only support simple basic mappings between properties and field values.
Using a configuration object gives more options and can do this kind of tricks and is also more readable.
https://www.baeldung.com/configuration-properties-in-spring-boot
Upvotes: 1