加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Jersey版本问题:找不到媒体类型= application/xml的MessageBody

发布时间:2020-12-16 07:59:16 所属栏目:百科 来源:网络整理
导读:在编写一个使用XML数据的简单Jersey客户端时,我遇到了这个异常“找不到媒体类型= application / xml的MessageBodyReader”.我的所有设置,包括作为maven依赖项的jersey-client都很好. 我使用的版本是2.17.一旦我将版本降级到2.15,它就开始正常工作了.任何人都
在编写一个使用XML数据的简单Jersey客户端时,我遇到了这个异常“找不到媒体类型= application / xml的MessageBodyReader”.我的所有设置,包括作为maven依赖项的jersey-client都很好.
我使用的版本是2.17.一旦我将版本降级到2.15,它就开始正常工作了.任何人都可以解释版本2.17需要包含哪些依赖项才能工作.

Maven依赖(适用于2.15及更低版本)

<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>${jersey.version}</version>
</dependency>

用于使用服务的Java Code Snippet

Client c = ClientBuilder.newClient();
WebTarget target = null;
target = c.target(Main.BASE_URI_XML);

String customerId = "415D7AB5";

XYZ response = target.path(customerId).request(MediaType.APPLICATION_XML).get(XYZ.class);
看看 27.3. Migrating from Jersey 2.15 to 2.16

27.3.1.1. JAX-B providers separated from the core

From version 2.16 onwards,all JAX-B providers are being bundled in a separate module.

<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-jaxb</artifactId>
    <version>2.17</version>
</dependency>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读