在编写一个使用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>
Run Code Online (Sandbox Code Playgroud)
用于使用服务的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);
Run Code Online (Sandbox Code Playgroud)