泽西版问题:找不到媒体类型= application/xml的MessageBodyReader [英] Jersey version issue: MessageBodyReader not found for media type=application/xml
问题描述
在编写使用XML数据的简单Jersey客户端时,我遇到了此异常找不到针对media type = application/xml的MessageBodyReader".我所有的设置,包括作为Maven依赖项的jersey-client都很好. 我使用的版本是2.17.一旦我将版本降级到2.15,它就可以正常工作.任何人都可以解释一下要使版本2.17正常运行需要包含哪些依赖项.
While writing a simple Jersey client that was consuming XML data, I came across this exception "MessageBodyReader not found for media type=application/xml". All of my settings, including the jersey-client as maven dependencies was just fine. The version that I was using was 2.17. Once I degraded the version to 2.15 it started working fine. Can anyone explain what dependencies that needs to be included for version 2.17 to work.
Maven依赖关系(适用于2.15及更低版本)
Maven Dependency (works on 2.15 and lower)
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
</dependency>
使用该服务的Java代码段
Java Code Snippet for consuming the service
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.1.1.与核心区分开的JAX-B提供程序
从2.16版开始,所有JAX-B提供程序都捆绑在一个单独的模块中.
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>
这篇关于泽西版问题:找不到媒体类型= application/xml的MessageBodyReader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!