Код: Выделить всё
ClientBuilder.newClient()
Код: Выделить всё
Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: Provider for jakarta.ws.rs.client.ClientBuilder cannot be found
Как это исправить?
Я добавил зависимость jakarta 10.0.0 в pom-файл проекта maven. Что еще мне добавить?
Код: Выделить всё
package com.tbs.companyclient;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.MediaType;
/**
*
* @author tom
*/
public class CompanyWebClient {
public static void main(String[] args) {
// Create a JAX-RS client
Client client = ClientBuilder.newClient();
// Define the target endpoint of the RESTful web service
WebTarget target = client.target("http://localhost:8080/CompanyWebService/resources/company/departments");
// Make a GET request to the target endpoint and specify the expected response media type
String response = target.request(MediaType.APPLICATION_JSON).get(String.class);
// Print the response
System.out.println("Response:");
System.out.println(response);
// Close the client
client.close();
}
}
Код: Выделить всё
4.0.0
com.tbs
CompanyClient
1.0
jar
UTF-8
22
22
com.tbs.companyclient.CompanyClient
RESTful Client for the CompanyWebService
CompanyWebClient
jakarta.platform
jakarta.jakartaee-api
10.0.0
Подробнее здесь: https://stackoverflow.com/questions/780 ... t-be-found