Rest Wildfly Swarm Jax RS客户端
我有一个Wildfly Swarm服务器正在运行,但它需要向另一个rest服务器发送请求。 我尝试使用JAX-RS客户端,但失败了 执行请求时截取的代码是Rest Wildfly Swarm Jax RS客户端,rest,client,jax-rs,wildfly-swarm,Rest,Client,Jax Rs,Wildfly Swarm,我有一个Wildfly Swarm服务器正在运行,但它需要向另一个rest服务器发送请求。 我尝试使用JAX-RS客户端,但失败了 执行请求时截取的代码是 Client client = ClientBuilder.newClient(); Invocation.Builder request = client.target(automatonUri) .path("/self/isAlive") .request(MediaType.APPLICATION_JSON); boo
Client client = ClientBuilder.newClient();
Invocation.Builder request = client.target(automatonUri)
.path("/self/isAlive")
.request(MediaType.APPLICATION_JSON);
boolean isAlive = request.get(Boolean.class);
当运行这个时,我总是得到java.lang.ClassNotFoundException:org.glassfish.jersey.client.JerseyClientBuilder异常
我使用以下分数:
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>ejb</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>cdi</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>microprofile</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>logging</artifactId>
</dependency>
我试着加上
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jaxrs-client-api</artifactId>
</dependency>
但是我只得到com.sun.jersey.api.container.ContainerException:运行任何junit测试时都不存在WebApplication提供程序
有什么想法吗?或者任何我可以看的例子?
谢谢。我认为您需要添加对RESTEasy客户端的显式依赖,例如
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>${version.org.jboss.resteasy}</version>
</dependency>
按预期工作。我甚至把它放在里面了,但它打破了剩下的一切。我没有意识到我应该把它设置为“提供”。谢谢