小编cri*_*gua的帖子

NoClassDefFoundError: javax/ws/rs/client/ClientBuilder

我正在尝试创建一个非常简单的 Rest Client。我正在使用:Netbeans 8 maven 项目

依赖:

    <dependencies>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.1-m01</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.24.1</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <version>3.0.16.Final</version>
        </dependency>
    </dependencies>
Run Code Online (Sandbox Code Playgroud)

和代码:

public class Client_con {

public static final String BASE_URI = "http://localhost:8000/test";
public static final String PATH_NAME = "/h";
public static void main (String [] args){

   Client client = ClientBuilder.newClient();

    //WS text get
    WebTarget target = client.target(BASE_URI).path(PATH_NAME);
    String res = target.request().get().readEntity(String.class);
    System.out.println(res);
}
}
Run Code Online (Sandbox Code Playgroud)

但我总是得到同样的错误:

  Exception in thread "main" java.lang.NoClassDefFoundError: 
   javax/ws/rs/client/ClientBuilder
      at ah.consumer.Client_con.main(Client_con.java:38)
  Caused by: java.lang.ClassNotFoundException: …
Run Code Online (Sandbox Code Playgroud)

rest client javax

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

client ×1

javax ×1

rest ×1