JAXB生成类问题

时间:2018-03-29 21:13:17

标签: java xml xsd jaxb cxf

我正在尝试使用Eclipse生成一些Java类。但不知何故,我遇到了问题。当我尝试这样做时,我收到了这个错误:

parsing a schema...
compiling a schema...
[ERROR] A class/interface with the same name "com.xml.apis.schemas.MPLSVPNListItem" is already in use. Use a class customization to resolve this conflict.
  line 9 of file:/C:/Workspace/MyFiles/WebContent/WEB-INF/XSDFiles/jaxb_binding.xml

[ERROR] (Relevant to above error) another "MPLSVPNListItem" is generated from here.
  line 3122 of file:/C:/Workspace/MyFiles/WebContent/WEB-INF/XSDFiles/APIcTypes.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 9 of file:/C:/Workspace/MyFiles/WebContent/WEB-INF/XSDFiles/jaxb_binding.xml

[ERROR] (Related to above error) This is the other declaration.
  line 3122 of file:/C:/Workspace/MyFiles/WebContent/WEB-INF/XSDFiles/APIcTypes.xsd

Failed to produce code.

我正在使用JAXB绑定文件(jaxb_binding.xml):

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1">

    <jxb:bindings
        schemaLocation="APIcTypes.xsd">
        <jxb:bindings
            node="//xs:complexType[@name='MPLS-VPNListItem']">
            <jxb:class name="MPLS_VPNListItem" />
        </jxb:bindings>
    </jxb:bindings>
    <jxb:bindings
        schemaLocation="APIcTypes.xsd">
        <jxb:bindings
            node="//xs:complexType[@name='MPLSVPNListItem']">
            <jxb:class name="MPLSVPNListItem" />
        </jxb:bindings>
    </jxb:bindings>
</jxb:bindings>

因为我认为这两个标签导致了这个问题。

我不得不说APIcTypes.xsd实际上是我试图为其生成类的XSD中的导入。

包含结构如下: API.xsd - &gt; APIRequests.xsd - &gt; APIcTypes.xsd - &gt; APIsTypes.xsd。

我希望这是可以理解的。如果您需要更多信息,请告诉我。只是不能让它工作!

0 个答案:

没有答案