The following three are required
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.27</version>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.26</version>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.26</version>
Not enough
java.lang.ClassNotFoundException: org.glassfish.jersey.internal.l10n.LocalizableMessageFactory$ResourceBundleSupplier
I don't understand this error
✩ I want to call the API of http: // localhost: 8080 / test / api1
public void excute(RequestData req) {
String result = ClientBuilder.newClient()
//URL with fixed cooperation destination
.target("http://localhost:8080")
//Where the path changes depending on the link destination
.path("/test/api1")
//Where to decide whether to request in Xml format or JSON format
//Specify this for xml → APPLICATION_XML_TYPE
.request(MediaType.APPLICATION_JSON_TYPE)
//Data plunge
//Specify in what format to receive the response with MediaType This time JSON
.post(Entity.entity(req, MediaType.APPLICATION_JSON), String.class);
//Display response on standard output
System.out.println(result);
}
Recommended Posts