Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jersey 2.x does not contain WebResource and resource class. What can I use instead?

I am trying to create a web API using Jersey. I am trying to run a method similar to this:

WebResource r = c.resource("http://localhost:8080/Jersey/rest/contacts");

However Jersey 2.x does not have a WebResource or Resource class. So what class can I use instead in order to have the uri http://localhost:8080/Jersey/rest/contacts as a parameter? This will be ran in a ContactClient class

like image 855
Ezra Zerihun Avatar asked Jun 15 '15 19:06

Ezra Zerihun


1 Answers

Have a look at the Client API from the Jersey documentation. With Jersey 2.x you instead want to use WebTarget. For example

Client client = ClientBuilder.newClient();
WebTarget target = client.target(url);
Response response = target.request().get();

See the documentation I linked to for much more information and examples.

like image 153
Paul Samsotha Avatar answered Oct 22 '22 16:10

Paul Samsotha