【问题标题】:Wildfly-Swarm Jax-RS ClientWildfly-Swarm Jax-RS 客户端
【发布时间】:2018-02-05 09:08:15
【问题描述】:

我有一个 Wildfly-Swarm 服务器正在运行,但它需要向另一个 rest-server 发送请求。 我尝试使用 JAX-RS-Client,但失败了。

执行请求的代码片段是

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>

但是当我运行任何junit测试时,我只会得到com.sun.jersey.api.container.ContainerException: No WebApplication provider is present

有什么想法吗?或者我可以看的任何例子? 谢谢。

【问题讨论】:

    标签: rest client jax-rs wildfly-swarm


    【解决方案1】:

    我认为您需要添加对 RESTEasy Client 的显式依赖,例如

            <dependency>
                <groupId>org.jboss.resteasy</groupId>
                <artifactId>resteasy-client</artifactId>
                <version>${version.org.jboss.resteasy}</version>
            </dependency>
    

    【讨论】:

    • 按预期工作。我什至有它,但它破坏了整个 REST-Endpoint。我没有意识到我应该将其设置为提供。非常感谢
    猜你喜欢
    • 2015-10-15
    • 2023-04-04
    • 2016-09-13
    • 2016-02-21
    • 1970-01-01
    • 2016-12-06
    • 2013-06-03
    • 2016-01-10
    • 2019-09-25
    相关资源
    最近更新 更多