JAXB:为共享一个公共 XSD 的两个 XSD 生成类
我有2个服务XSD文件AService.xsd和BService.xsd,每个文件都有不同的目标命名空间。这两者都使用称为common.xsd的通用XSD。我使用JAXB Maven插件来生成类。操作方法如下:
<execution>
<id>generate-package</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<extension>true</extension>
<schemaIncludes>
<include>schema/Aservice.xsd</include>
<include>schema/Bservice.xsd</include>
</schemaIncludes>
<bindingIncludes>
<include>schema/*.xjb</include>
</bindingIncludes>
<generatePackage>com.schema</generatePackage>
<generateDirectory>src/main/java</generateDirectory>
</configuration>
</execution>
当我尝试运行这个时,我得到以下错误。 在 common.xsd 中定义ValidationType
org.xml.sax.SAXParseException: A class/interface with the same name "com.schema.ValidationType" is already in use. Use a class customization to resolve this conflict.
..........
org.xml.sax.SAXParseException: (Relevant to above error) another "ValidationType" is generated from here.
......
com.sun.istack.SAXParseException2: Two declarations cause a collision in the ObjectFactory class.
如果我在2个不同的执行中运行2个服务xsds,生成到2个不同的包中,我在2个不同的包中得到相同的类。ValidationType
关于如何使 JAXB 识别共享模式的任何想法?