-1

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

Community
  • 1
  • 1
robert trudel
  • 5,283
  • 17
  • 72
  • 124

1 Answers1

-1

try getForEntity(URI url,Class responseType)

    @GetMapping(value = "/visits")
        public ResponseEntity<CustomPageImpl<VisitDto>> getVisits(Pageable pageRequest) {
              ResponseEntity<CustomPageImpl<VisitDto>> response = restTemplate.getForEntity(Uri.parse("url"), new TypeReference<CustomPageImpl<VisitDto>>() {});
return response;
        }
kuhajeyan
  • 10,727
  • 10
  • 46
  • 71