I have below in my yaml
endpointWithType: {abc: 'POST', def: 'GET'}
I am map it in my spring bean as follow,
@Value("#{'${endpointWithType}'}") Map<String,String> endpointWithType;
I get below error,
Cannot convert value of type [java.lang.String] to required type [java.util.Map]: no matching editors or conversion strategy found
How can I map a configuration map representation to a java hashmap?
Advertisement
Answer
In yaml try to format it in this way:
endpointWithType: abc: POST def: GET
Or try this way:
endpointWithType: '{abc: "POST", def: "GET"}'
@Value("#{${endpointWithType}}") private Map<String, String> endpointWithType;