【问题标题】:How to interpret javax.xml.bind.UnmarshalException如何解释 javax.xml.bind.UnmarshalException
【发布时间】:2013-09-13 09:48:37
【问题描述】:

当我尝试将 xml 文件转换为其 java 对应文件时收到此错误:

09.09.2013 13:58:26 ERROR [manager.getContentsUnmarshalled():154] There was an error parsing the file: "props.xml". JAXB unmarshalling exception; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"newImageOverlay"). Expected elements are <{}GenericData>,<{}VirtualComponent>,<{}application_constants>,<{}channel>

我认为这个错误表示 xml 文件中存在意外元素?

在异常消息中,jaxb 如何识别“预期元素”?标识符&lt;{}GenericData&gt;,&lt;{}VirtualComponent&gt;,&lt;{}application_constants&gt;,&lt;{}channel&gt; 在哪里指定?

【问题讨论】:

  • 能贴出相关的xml吗?

标签: java spring jaxb xsd unmarshalling


【解决方案1】:

我需要将此条目添加到我的应用程序上下文文件中:

<oxm:jaxb2-marshaller>
<oxm:jaxb2-marshaller id="marshaller">
    <oxm:class-to-be-bound name="com.MyGeneratedClass"/>
</oxm:jaxb2-marshaller>

【讨论】:

    猜你喜欢
    • 2017-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-23
    • 2014-06-08
    • 2020-02-07
    相关资源
    最近更新 更多