Java 找不到 ClientBuilder 类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20763493/
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-08-13 04:09:47  来源:igfitidea点击:

ClientBuilder class not found

javarestjakarta-eejerseyjersey-client

提问by MChan

I am trying to build a RESTFul client using Jersey framework, so I added the following class:

我正在尝试使用 Jersey 框架构建一个 RESTFul 客户端,所以我添加了以下类:

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

public class ActivityClient {
    private Client client;  
    public ActivityClient(){        
        client = ClientBuilder.newClient();
    }   
        //...code
}

but I am getting an error class ClientBuilder not found, even though I have the following jars under WEB-INF/lib and under the application class path:

但是我得到一个错误类 ClientBuilder not found,即使我在 WEB-INF/lib 和应用程序类路径下有以下 jars:

asm-3.1.jar
Hymanson-core-asl-1.9.2.jar
Hymanson-jaxrs-1.9.2.jar
Hymanson-mapper-asl-1.9.2.jar
Hymanson-xc-1.9.2.jar
jersey-client-1.17.1.jar
jersey-core-1.17.1.jar
jersey-json-1.17.1.jar
jersey-server-1.17.1.jar
jersey-servlet-1.17.1.jar
jettison-1.1.jar
jsr311-api-1.1.1.jar

So can someone please tell me which jar I am missing here? and where I can find it? I have searched the web and the only jar I found that has ClientBuilder is related to the RESTEasy framework, so I don't think that it is related.

那么有人可以告诉我我在这里缺少哪个罐子吗?我在哪里可以找到它?我在网上搜索过,我发现唯一一个有 ClientBuilder 的 jar 与 RESTEasy 框架有关,所以我认为它没有关系。

Thanks for your time

谢谢你的时间

采纳答案by NickL

As far as I can see, ClientBuilderis part of the Jersey 2.x API, and you are using Jersey 1.17.1. So either use a new version, or use the 1.17.1 API which can be found here

据我所知,ClientBuilder是 Jersey 2.x API 的一部分,您使用的是 Jersey 1.17.1。所以要么使用新版本,要么使用 1.17.1 API,可以在这里找到