-1

Javax.ws.rs client implementation

Client client = ClientBuilder.newClient();
Response response = client.target(URI.contextPathUI + "/api/item").request().get();

Spring rest template implementation

HashMap<String, String> param = new HashMap<>();
param.put("id", itemId);
return restTemplate.getForObject(URI.contextPathUI + "/api/item", ArrayList.class, param);
Vsu Chuchra
  • 23
  • 1
  • 7

1 Answers1

-1

The difference lies what you are building your functionality against, in each case.

For the JAX-RS Client case, you are building your code on top of a specification JAX-RS. This specification doesn't have any implementation for the Client, so you also must depend on an implementation such as Jersey, which is fully compliant with the JAX-RS spec.

In the Spring Rest Template case, this is a non-JAX-RS compliant implementation. The Spring Rest Template is part of the whole Spring ecosystem, which is separate from the Java EE ecosystem that JAX-RS belongs to (Java / Jakarta EE).

Mario Ishac
  • 5,060
  • 3
  • 21
  • 52
  • I meant client class in javax.ws.rs.client package, is there a difference between using that or spring rest template. Is one btter than the other in someway ? – Vsu Chuchra Oct 23 '19 at 19:06