We are using restemplate in a commons package for our application. So we need to use generic types.
I read many solutions about that, but none seems to not work for us, and we constantly get (on the client side):
java.util.LinkedHashMap cannot be cast to nc.gouv.dsf.ranch.model.Pays
Here is the code (sum up):
public List<T> findAll(C criteria) {
[...]
ResponseEntity<List<T>> response =
restTemplateFactory.getRestTemplate().exchange(
url,
HttpMethod.GET,
new HttpEntity<>(createHttpHeaders(srvId)),
new ParameterizedTypeReference<List<T>>() {}
);
return response.getBody();
}
I though ParameterizedTypeReference what the solution to this kind of problems but its doesn't work.
PS: we are using springboot 1.3.1.RELEASE