map yaml config to a java hashmap

Tags: , ,

I have below in my yaml

endpointWithType: {abc: 'POST', def: 'GET'}  

I am map it in my spring bean as follow,

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?


In yaml try to format it in this way:

  abc: POST
  def: GET

Or try this way:

endpointWithType: '{abc: "POST", def: "GET"}'  
private Map<String, String> endpointWithType;

Source: stackoverflow