我有一个球衣客户。我在客户端类中有以下导入
./src/com/uciext/ws/class2/client/StudentClient.java:3: error: package javax.ws.rs.client does not exist
import javax.ws.rs.client.Client;
^
当我编译应用程序时,我得到
This is the error trace
./src/com/uciext/ws/hw2/client/InventoryClient.java:4: error: package javax.ws.rs.client does not exist
import javax.ws.rs.client.Client;
^
./src/com/uciext/ws/hw2/client/InventoryClient.java:5: error: package javax.ws.rs.client does not exist
import javax.ws.rs.client.ClientBuilder;
^
./src/com/uciext/ws/hw2/client/InventoryClient.java:6: error: package javax.ws.rs.client does not exist
import javax.ws.rs.client.Entity;
^
./src/com/uciext/ws/hw2/client/InventoryClient.java:7: error: package javax.ws.rs.client does not exist
import javax.ws.rs.client.Invocation;
^
./src/com/uciext/ws/hw2/client/InventoryClient.java:8: error: package javax.ws.rs.client does not exist
import javax.ws.rs.client.WebTarget;
^
./src/com/uciext/ws/hw2/client/InventoryClient.java:9: error: package javax.ws.rs.core does not exist
import javax.ws.rs.core.MediaType;
^
./src/com/uciext/ws/hw2/client/InventoryClient.java:10: error: package javax.ws.rs.core does not exist
import javax.ws.rs.core.Response;
^
./src/com/uciext/ws/hw2/client/InventoryClient.java:15: error: cannot find symbol
Client client = ClientBuilder.newClient();
^
symbol: class Client
location: class InventoryClient
./src/com/uciext/ws/hw2/client/InventoryClient.java:15: error: cannot find symbol
Client client = ClientBuilder.newClient();
^
symbol: variable ClientBuilder
location: class InventoryClient
./src/com/uciext/ws/hw2/client/InventoryClient.java:16: error: cannot find symbol
WebTarget myResource = client.target("http://127.0.0.1:8080/inventory/rest/catalog");
^
symbol: class WebTarget
location: class InventoryClient
./src/com/uciext/ws/hw2/client/InventoryClient.java:17: error: package Invocation does not exist
Invocation.Builder builder = myResource.request(MediaType.TEXT_PLAIN);
^
./src/com/uciext/ws/hw2/client/InventoryClient.java:17: error: cannot find symbol
Invocation.Builder builder = myResource.request(MediaType.TEXT_PLAIN);
^
symbol: variable MediaType
location: class InventoryClient
12 errors
如何解决此问题
已编辑:
JAXB_PATH=./lib/jaxb-ri-2.2.7/lib
JAXB_LIB=$JAXB_PATH/jaxb-api.jar:$JAXB_PATH/jaxb-core.jar:$JAXB_PATH/jaxb-impl.jar:$JAXB_PATH/jaxb-jxc.jar:$JAXB_PATH/jaxb-xjc.jar
JAXRS_PATH=./lib/jaxrs-ri/lib
JAXRS_API=./lib/jaxrs-ri/api
JAXRS_LIB=$JAXRS_PATH/jersey-server.jar:$JAXRS_PATH/jersey-common.jar:$JAXRS_PATH/jersey-container-servlet.jar:$JAXRS_PATH/jersey-container-servlet-core.jar:$JAXRS_API/javax.ws.rs-api-2.0.jar
CLASSPATH=$CLASSPATH:./lib/jaxrs-ri/api
CLASSPATH=$CLASSPATH:./lib/jaxb-ri-2.2.7/lib
CLASSPATH=$CLASSPATH:./lib/jaxrs-ri/lib
javac -classpath $JAXB_LIB:$JAXRS_LIB:. -d classes ./src/com/uciext/ws/hw2/util/*.java ./src/com/uciext/ws/hw2/backend/model/*.java ./src/com/uciext/ws/hw2/backend/*.java ./src/com/uciext/ws/hw2/backend/impl/*.java ./src/com/uciext/ws/hw2/service/model/catalog/*.java ./src/com/uciext/ws/hw2/service/model/order/*.java ./src/com/uciext/ws/hw2/service/model/orderconfirm/*.java ./src/com/uciext/ws/hw2/service/*.java ./src/com/uciext/ws/hw2/service/impl/*.java
javac -classpath $JAXB_LIB:$JAXRS_LIB:. -d classes ./src/com/uciext/ws/hw2/client/model/catalog/*.java ./src/com/uciext/ws/hw2/client/model/order/*.java ./src/com/uciext/ws/hw2/client/model/orderconfirm/*.java ./src/com/uciext/ws/hw2/client/*.java
这是c.sh。我使用球衣2.2.7。我下载了jersey 2.2.7并将其复制到我的lib文件夹中。我可以使用错误版本的jar。
docker run --name grpcserver -p 8081:8081 -it -d grpcserver
答案 0 :(得分:0)
您是否包含了获取此程序包实现的依赖项?
如果您正在使用maven this,请提供详细信息。
对于库版本,请从here下载库,并按照以下tutorial添加所需的jar。尽管Client类在jaxrs-ri \ api jar中可用。
答案 1 :(得分:0)
您想抓住this zip file并确保jaxrs-ri/api/jakarta.ws.rs-api-2.1.6.jar
在您的类路径中。