Spring RestTemplate with paginated API
<p>Our REST APIs are returning results in Pages. Here is an example of one Controller</p>

<pre><code>@RequestMapping(value = "/search", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=UTF-8")
@ResponseStatus(HttpStatus.OK)
public Page&lt;MyObject&gt; findAll(Pageable pageable) {
  ...
}
</code></pre>

<p>Is there an easy way to consume that API with RestTemplate?</p>

<p>if we do</p>

<pre><code>ParameterizedTypeReference&lt;Page&lt;MyObject&gt;&gt; responseType = new ParameterizedTypeReference&lt;Page&lt;MyObject&gt;&gt;() { };

ResponseEntity&lt;Page&lt;MyObject&gt;&gt; result = restTemplate.exchange(url, HttpMethod.GET, null/*httpEntity*/, responseType);

List&lt;MyObject&gt; searchResult = result.getBody().getContent();
</code></pre>

<p>it throws an exception </p>

<pre><code>org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not construct instance of org.springframework.data.domain.Page, 
problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information at [Source: java.io.PushbackInputStream@3be1e1f2; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.springframework.data.domain.Page, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information
</code></pre>

<p>Thank you in advance</p>