Błąd: Could not extract response: no suitable HttpMessageConverter found

0

Witam,

Próbuję skonsumować pewien webserwis rest, zwracający dane w formacie JSON. Powiedzmy, że zwracany JSON wygląda tak:

 
[
  {
    "_id": "55f9690f30ef6f210e2dc3a5",
    "ID": "74c4bf82-9f78-4df5-b9d7-6547e2a55eaa",
    "Name": "myLand, Saarbrücken",
    "__v": 0,
    "Shops": [
      {
        "ID": "b8eacee1-b2c6-48aa-ac6f-2e7fbe3a5d68",
        "Name": "ARA",
        "_id": "55f9690f30ef6f210e2dc3a6",
        "News": [
          {
            "ID": "d79b7f51-7d5c-4bd6-9321-e40c6e93788c",
            "ValidFrom": "2015-01-08T00:00:00",
            "ValidTo": "2015-09-30T00:00:00",
            "_id": "55f9690f30ef6f210e2dc3a7",
            "Texts": [
              {
                "ID": "TITLE",
                "Value": "11. Wochenspiegel Firmenlauf",
                "_id": "55f9690f30ef6f210e2dc3a9"
              },
              {
                "ID": "BODY",
                "Value": "Wir gratulieren zur ersten und gleich sehr erfolgreichen Teilnahme am 11.Wochenspiegel Firmenlauf in Dillingen,\r\nunsere Teams vom “Outlet center Wadgassen“ haben ihren Lauf mit tollen Zeiten abgeschlossen und hatten trotz\r\nhohen Temperaturen einen wunderbaren Tag – wie man sehen kann. Wir freuen uns schon jetzt auf nächstes Jahr!",
                "_id": "55f9690f30ef6f210e2dc3a8"
              }
            ]
          }
        ],
        "Texts": [
          {
            "ID": "DESCRIPTION",
            "Value": "Mit Tradition in die Zukunft Seit sechs Jahrzehnten steht ara für vielfältige Schuhmode erstklassiger Qualität,",
            "_id": "55f9690f30ef6f210e2dc3aa"
          }
        ]
      }
    ]
  }
]

Wygenerowałem z tego json-a klasy Java (za pomocą stronki http://www.jsonschema2pojo.org/ ), może nie będe przytaczać wszystkich, wystarczy główna, którą nazwałem Mall:

public class Mall
{

    private String Id;
    private String ID;
    private String Name;
    private int V;
    private List<Shop> Shops = new ArrayList<Shop>();
    private Map<String, Object> additionalProperties = new HashMap<String, Object>();

    /**
     * @return The Id
     */
    public String getId()
    {
        return Id;
    }

    /**
     * @param Id The _id
     */
    public void setId(String Id)
    {
        this.Id = Id;
    }

    /**
     * @return The ID
     */
    public String getID()
    {
        return ID;
    }

    /**
     * @param ID The ID
     */
    public void setID(String ID)
    {
        this.ID = ID;
    }

    /**
     * @return The Name
     */
    public String getName()
    {
        return Name;
    }

    /**
     * @param Name The Name
     */
    public void setName(String Name)
    {
        this.Name = Name;
    }

    /**
     * @return The V
     */
    public int getV()
    {
        return V;
    }

    /**
     * @param V The __v
     */
    public void setV(int V)
    {
        this.V = V;
    }

    /**
     * @return The Shops
     */
    public List<Shop> getShops()
    {
        return Shops;
    }

    /**
     * @param Shops The Shops
     */
    public void setShops(List<Shop> Shops)
    {
        this.Shops = Shops;
    }

    public Map<String, Object> getAdditionalProperties()
    {
        return this.additionalProperties;
    }

    public void setAdditionalProperty(String name, Object value)
    {
        this.additionalProperties.put(name, value);
    }

}

Webserwis wywołuję tak:

RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
Mall mall = restTemplate.getForObject(url, Mall.class);

No i przy wywoływaniu getForObject leci wyjątek:

Could not extract response: no suitable HttpMessageConverter found for response type [m.m.restspringtest.Mall.Mall] and content type [application/json]

W czym może być tu problem? Dlaczego Spring odmawia parsowania tego?

0

No cóż, nikt się nie kwapi, więc sam sobie odpowiem... byłem durniem bo to przecież jest tablica, więc nie Mall, tylko Mall[], dodatkowo dobrze było wygenerować adnotacje. Temat do zamknięcia jak sądzę.

1 użytkowników online, w tym zalogowanych: 0, gości: 1