Jersey 2.x不包含WebResource和资源类.我可以用什么呢?

Ezr*_*hun 6 java rest jersey jersey-2.0

我正在尝试使用Jersey创建一个Web API.我正在尝试运行类似于此的方法:

WebResource r = c.resource("http://localhost:8080/Jersey/rest/contacts");
Run Code Online (Sandbox Code Playgroud)

但泽西岛2.x没有WebResourceResource类.那么我可以使用哪个类来将uri http://localhost:8080/Jersey/rest/contacts作为参数?这将在ContactClient课堂上进行

Pau*_*tha 10

查看Jersey文档中的Client API.使用Jersey 2.x你想要使用WebTarget.例如

Client client = ClientBuilder.newClient();
WebTarget target = client.target(url);
Response response = target.request().get();
Run Code Online (Sandbox Code Playgroud)

有关更多信息和示例,请参阅我链接到的文档.