2016-10-27 6 views
-1

でサービスを消費アプリケーション、私はこのthreadでアリDehghaniの答えのように、残りのテンプレートは(1.4.1)春ブーツでrestTemplate

@GetMapping(value = "/visits") 
    public ResponseEntity<CustomPageImpl<VisitDto>> getVisits(Pageable pageRequest) { 
      return restTemplate.getForEntity("", new TypeReference<CustomPageImpl<VisitDto>>() {}); 
    } 

を消費しようと、私は

CustomPageImplを作成しますTypeReferenceについての

、import com.fasterxml.jackson.core.type.TypeReference;

私は

ResponseEntity<CustomPageImpl<VisitDto>> response = restTemplate.getForEntity(URI.create("url"), new TypeReference<ResponseEntity<CustomPageImpl<VisitDto>>>() {}); 

でこのメッセージ

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>) 

を取得

答えて

-1

だそれを存在しない解析し、URIのjavax.netに見える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; 
     } 
+0

を試してみてください同じエラーが出ますパーサーとそれはプライベートなので作成...同じエラーが発生する –