java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder 错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36167042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 01:01:34  来源:igfitidea点击:

java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder Error?

java

提问by Dreamers Org

I am encountering the error: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder however i have imported the classes so am not sure why it is popping up. My build.gradle and code is below:

我遇到了错误:java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder 但是我已经导入了这些类,所以我不确定它为什么会弹出。我的 build.gradle 和代码如下:

private String getAccessToken() {
    try {
        Log.e("tree","get access entered");
        javax.ws.rs.client.Client client = javax.ws.rs.client.ClientBuilder.newClient();
        javax.ws.rs.client.Entity<String> payload =
                javax.ws.rs.client.Entity.text("grant_type=client_credentials&redirect_uri=https://facebook.com/__");
        javax.ws.rs.core.Response response = client.target("https://v2.api.xapo.com/oauth2/token")
                .request(MediaType.TEXT_PLAIN_TYPE)
                .header("Authorization","Basic ___")
                .post(payload);
Log.e("tree","response completed");
            String body = response.readEntity(String.class);
            Log.e("tree","body "+body);
        } catch(Exception e) {
Log.e("tree","token exception "+e.getMessage());
        }
        return "";
    }

回答by Shmulik Klein

You are missing the org.glassfish.jersey.core:jersey-clientdependency.

您缺少org.glassfish.jersey.core:jersey-client依赖项。