In a spring boot (1.4.1) application, i try to consume a rest template
@GetMapping(value = "/visits")
public ResponseEntity<CustomPageImpl<VisitDto>> getVisits(Pageable pageRequest) {
return restTemplate.getForEntity("", new TypeReference<CustomPageImpl<VisitDto>>() {});
}
like the answer of Ali Dehghani in this thread, i create a CustomPageImpl
about TypeReference, import com.fasterxml.jackson.core.type.TypeReference;
i get this message
no suitable method found for getForEntity(String,<anonymous TypeReference<CustomPageImpl<VisitDto>>>)
method RestTemplate.<T#1>getForEntity(String,Class<T#1>,Object...) is not applicable
(cannot infer type-variable(s) T#1
(argument mismatch; <anonymous TypeReference<CustomPageImpl<VisitDto>>> cannot be converted to Class<T#1>))
method RestTemplate.<T#2>getForEntity(String,Class<T#2>,Map<String,?>) is not applicable
(cannot infer type-variable(s) T#2
(actual and formal argument lists differ in length))
method RestTemplate.<T#3>getForEntity(URI,Class<T#3>) is not applicable
(cannot infer type-variable(s) T#3
(argument mismatch; String cannot be converted to URI))
where T#1,T#2,T#3 are type-variables:
T#1 extends Object declared in method <T#1>getForEntity(String,Class<T#1>,Object...)
T#2 extends Object declared in method <T#2>getForEntity(String,Class<T#2>,Map<String,?>)
T#3 extends Object declared in method <T#3>getForEntity(URI,Class<T#3>)
With
ResponseEntity<CustomPageImpl<VisitDto>> response = restTemplate.getForEntity(URI.create("url"), new TypeReference<ResponseEntity<CustomPageImpl<VisitDto>>>() {});
get same error