未找到 ClientBuilder 类
我正在尝试使用 Jersey 框架构建一个 RESTFul 客户端,所以我添加了以下类:
I am trying to build a RESTFul client using Jersey framework, so I added the following class:
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
public class ActivityClient {
private Client client;
public ActivityClient(){
client = ClientBuilder.newClient();
}
//...code
}
但我得到一个错误类 ClientBuilder not found,即使我在 WEB-INF/lib 和应用程序类路径下有以下 jar:
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:
asm-3.1.jar
jackson-core-asl-1.9.2.jar
jackson-jaxrs-1.9.2.jar
jackson-mapper-asl-1.9.2.jar
jackson-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
那么有人可以告诉我我在这里缺少哪个罐子吗?我在哪里可以找到它?我在网上搜索过,我发现唯一有ClientBuilder的jar与RESTEasy框架有关,所以我认为它不相关.
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 是 Jersey 2.x API 的一部分,您使用的是 Jersey 1.17.1.所以要么使用新版本,要么使用 1.17.1 API,可以找到 这里
As far as I can see, ClientBuilder is 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
相关文章