【发布时间】:2016-09-29 15:54:10
【问题描述】:
我使用 JBoss 6.x EAP 和 RestEasy。
当我尝试在我的 Web 应用程序中包含 swagger.io 1.5.0 并尝试使用外部 jersey rest 客户端进行调用时,我注意到它给了我错误,因为由于忽略了 @ json 转换期间的 XMLElement(name="some_value")。
这可能是因为 jaxb 库覆盖了 JBoss 提供的库。
这是外部rest客户端的一段代码
// requestObject is a pojo with JAXB annotations
// When using swagger, the field @XmlElement name is ignored, therefore the object is unmashaled with myName instead of my_name as expected
// @XmlElement(name = "my_name"))
// String myName
ClientResponse response;
try {
response = client.resource(requestURI).queryParams(queryParams)
.type(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.post(ClientResponse.class, requestObject);
我尝试包含最新版本的 xml 提供程序,如下所示:
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.8.3</version>
</dependency>
但没有任何变化。
关于如何使用原始 jackson / jaxb 提供程序进行对象映射的任何建议?
【问题讨论】:
标签: java xml jboss jaxb swagger