An Abstract controller class requires List of objects from REST. While using Spring RestTemplate its not mapping it to required class instead it returns Linked HashMAp
I did this a bit different. In my situation, I had a base class where I was implementing a set of CRUD operations and then using derived classes to implement specific resource types.
In the base class, I was trying to define a ParameterizedTypeReference as follows:
ParameterizedTypeReference> typeRef =
new ParameterizedTypeReference>() {};
This didn't work so I ended up creating an abstract method in the base class:
protected abstract ParameterizedTypeReference>
getServicePagedResultTypeRef();
and then in the derived classes:
@Override
protected ParameterizedTypeReference>
getServicePagedResultTypeRef() {
return new ParameterizedTypeReference>() {};
}
I could then use that in the base class like:
ResponseEntity> response = lbRestTemplate.exchange(
uri, HttpMethod.GET, null, getServicePagedResultTypeRef(), uriVariables);