基于XSD生成Java类而不进行块替换?

时间:2015-07-08 13:16:53

标签: java maven xsd unmarshalling jaxb2

使用jaxb(maven-jaxb2-plugin)编译器进行maven构建时出现以下错误

A class/interface with the same name "org.somePackage.customer" is already in use.
    Use a class customization to resolve this conflict.
        at com.sun.tools.xjc.util.CodeModelClassFactory.createClass(CodeModelClassFactory.java:121)
        at com.sun.tools.xjc.util.CodeModelClassFactory.createClass(CodeModelClassFactory.java:82)
        at com.sun.tools.xjc.generator.bean.ImplStructureStrategy$1.createClasses(ImplStructureStrategy.java:82)
        at com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassDef(BeanGenerator.java:437)
        at com.sun.tools.xjc.generator.bean.BeanGenerator.getClazz(BeanGenerator.java:469)
        at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:194)
        at com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:166)
        at com.sun.tools.xjc.model.Model.generateCode(Model.java:290)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.generateCode(XJC22Mojo.java:70)

什么行不通

 <xsd:element name="customer" >
         ........
 </xsd:element>
 <xsd:element name="permanentCustomer" type="customer"/>

什么有用

<xsd:element name="customer" block="substitution">
 ........
</xsd:element>
<xsd:element name="permanentCustomer" type="customer"/>

我不确定为什么在这里删除块属性创建问题?

我的猜测是jaxb编译器再次尝试基于元素名称=“permanentCustomer”创建客户类,它已经基于元素名称=“customer”创建了它。因此,我不希望在解组时为permanentCustomer创建java对象,因为它已在客户创建时创建。有没有办法做到这一点?

0 个答案:

没有答案