org.glassfish.jersey.client.ClientResponse不能应用于给定的类型

时间:2016-09-07 14:17:11

标签: java jersey java-8

我有这段代码:

    Version version = commonClient.authorizedRequestBuilder(commonClient.webTarget
            .path("/apps/blabla/default/" + appName + "/" + appName)
            .queryParam("object_type", "app"))
            .accept(MediaType.APPLICATION_JSON_TYPE)
            .get(ClientResponse.class)
            .getEntity(new GenericType<Version>() {});

如何修复它以解决此错误?

Error:(38, 17) java: method getEntity in class org.glassfish.jersey.client.ClientResponse cannot be applied to given types;
  required: no arguments
  found: <anonymous javax.ws.rs.core.GenericType<linqmap.supportool.services.gas.dto.Version>>
  reason: actual and formal argument lists differ in length

1 个答案:

答案 0 :(得分:0)

getEntity()方法不接受任何参数,因此您无法传递(new GenericType(){})

使用以下代替

Version version = commonClient.authorizedRequestBuilder(commonClient.webTarget
        .path("/apps/blabla/default/" + appName + "/" + appName)
        .queryParam("object_type", "app"))
        .accept(MediaType.APPLICATION_JSON_TYPE)
        .get(ClientResponse.class)
        .getEntity();