【发布时间】:2014-10-02 03:08:16
【问题描述】:
我正在使用 JAXB 从 xsd 模式创建类。 有没有办法标记单个 complexType,以便将它们发送到不同的目标包,而不是将它们全部发送到同一个包?
我需要这个的原因是很多生成的 java 类将被替换为来自不同来源的其他同名类。从一个目标文件夹中手动删除所有未使用的类是一种痛苦。将所有不需要的类放在一个不同的文件夹中会更容易,然后当我将输出导入 eclipse 时我可以忽略它。当我试图从 xsd 文件中的不需要的类中简单地排除 complexType 定义时,每次遇到不需要的类型之一的属性时,xjc 都会抛出错误。我需要保留属性引用,但我希望对这些属性的最终 java 引用指向已经通过其他方式生成的同名类。
这是我编译类的 build.xml 方法。我将如何改变它?
<!--compile Java source files-->
<target name="compile" description="Compile all Java source files">
<echo message="Compiling the schema..." />
<mkdir dir="gen-src" />
<mkdir dir="gen-src/primer/po" />
<xjc schema="somefilename.xsd" package="primer.po" destdir="gen-src" binding="rename.xjb">
<produces dir="gen-src/primer/po" includes="**/*.java" />
</xjc>
<echo message="Compiling the java source files..." />
<mkdir dir="classes" />
<javac destdir="classes" debug="on">
<src path="src" />
<src path="gen-src" />
<classpath refid="classpath" />
</javac>
</target>
【问题讨论】: