简体   繁体   中英

org.glassfish.jersey.client.ClientResponse cannot be applied to given types

I have this code:

    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>() {});

how can I fix it to solve this error?

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

the getEntity() method accepts no Parameters so you can't pass (new GenericType() {})

use the following instead

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM