我使用maven-jaxb2-plugin从xsd生成jaxb注释类。我有很多XSD文件像:从具有类似属性名称的XSD生成JAXB类
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="A3">
<xs:complexType>
<xs:sequence>
<xs:element name="loginPartner">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="login"/>
<xs:element type="xs:string" name="password"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="A3">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="errorCode"/>
<xs:element type="xs:string" name="errorDescription"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
当我运行Maven插件它给了我一个错误:
[ERROR] Error while parsing schema(s).Location [ file:schema1.xsd{10,16}]. org.xml.sax.SAXParseException: 'A3' is already defined
有什么办法解决这一问题? 其实我有很多XSD表示向/从服务器发送请求/响应消息。我想简化创建,验证,解析消息。也许有另一种解决方案吗?
你能从你的'pom.xml'发表您的插件配置?我现在无法找到(达到)'maven-jaxb2-plugin'的文档,并且我不明白所有选项。如果可行,可以尝试为模式添加一个'targetNamespace =“http://任何”'“属性来区分具有相同名称的类型。可以将每个模式文件编译到不同的Java包中。这也可以。为此,您可能必须为该插件指定multipe [executions](http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag)。 – 2011-12-29 08:29:14