简体   繁体   English

Unmarshall xml文件,UnrecognizedPropertyException:无法识别的字段“”

[英]Unmarshall xml file, UnrecognizedPropertyException: Unrecognized field “”

I was wondering if somebody can help me out. 我想知道是否有人可以帮助我。 I created a small maven project so you can easily run the test. 我创建了一个小Maven项目,以便您可以轻松运行测试。 For testing you can run the JUnit test UnmarshalTest.unmarshalResponse() which fails with a exception. 为了进行测试,您可以运行JUnit测试UnmarshalTest.unmarshalResponse(),该测试会失败并发生异常。

I'm trying to read a value from a xml element with an attribute but somehow I'm not able to to that. 我正在尝试从具有属性的xml元素读取值,但是以某种方式我无法做到这一点。 Any idea why? 知道为什么吗?

XML looks like: XML看起来像:

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
    <id_lang xlink:href="http://prestashop.local/api/languages/1">57</id_lang>
</prestashop>

Thx a lot 多谢

/david /大卫

[Update] Sorry, I prepared already the code but forgot to upload it ... https://drive.google.com/open?id=1t99zBxN7juA9RgNhS6S9UCCFSYxksnXW [更新]抱歉,我已经准备好代码了,但是忘了上传它... https://drive.google.com/open?id=1t99zBxN7juA9RgNhS6S9UCCFSYxksnXW

The full message coming back is such as: 返回的完整消息如下:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "" (class com.smooth.systems.test.TagValue), not marked as ignorable (2 known properties: "idLang", "href"])
 at [Source: (File); line: 3, column: 76] (through reference chain: com.smooth.systems.test.TestWrapper["id_lang"]->com.smooth.systems.test.TagValue[""])

Which points to the 76 in the body of the <id_lang> element in the example above - hence the missing field name. 在上面的示例中,它指向<id_lang>元素主体中的76 ,因此缺少字段名称。

(It is line 3, there's another <?xml ... ?> declaration line not seen in the sample xml). (这是第3行,还有另外一个<?xml ... ?>声明行在示例xml中未显示)。

Switching the @XmlValue annotation to @JacksonXmlText on the owning TagValue class seems to work better. 切换@XmlValue注释@JacksonXmlText上拥有TagValue类似乎更好地工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UnrecognizedPropertyException:无法识别的字段“ sections” - UnrecognizedPropertyException: Unrecognized field “sections” UnrecognizedPropertyException无法识别的字段“ resourceType”? - UnrecognizedPropertyException Unrecognized field “resourceType”? 构建失败,出现 UnrecognizedPropertyException: Unrecognized field<section> 错误</section> - Build failed with UnrecognizedPropertyException: Unrecognized field <Section> error Java \\ JSON:UnrecognizedPropertyException:无法识别的字段“ CefMessagesGenerators”错误 - Java\JSON: UnrecognizedPropertyException: Unrecognized field “CefMessagesGenerators” error 无法使用杰克逊,com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException将xml绑定到pojo:无法识别的字段 - can not bind xml to pojo using jackson, com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段 - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field 错误:com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段 - error :com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field 解决com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段 - resolving com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段“ g” - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field “g” 如何解组此XML文件结构 - How to unmarshall this XML file structure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM