我们使用 jaxb2-plugin 生成一些类,并且在创建 JaxbContext 时依赖于对象工厂。
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<id>Messaging</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<packageName>com.abc.message</packageName>
<schemaIncludes>
<schemaInclude>abc/api/message/main.xsd</schemaInclude>
</schemaIncludes>
<bindingIncludes>
<bindingInclude>abc/api/message/binding.xjb</bindingInclude>
</bindingIncludes>
<schemaDirectory>${basedir}/src/main/resources/xsd</schemaDirectory>
<bindingDirectory>${basedir}/src/main/resources/xsd</bindingDirectory>
<generateDirectory>jaxb2-generated-sources/messaging</generateDirectory>
<removeOldOutput>true</removeOldOutput>
<extension>true</extension>
<verbose>false</verbose>
<args>
<arg>-target</arg>
<arg>2.2</arg>
<arg>-Xequals</arg>
<!--arg>-XhashCode</arg-->
<arg>-Xlocator</arg>
<arg>-Xinheritance</arg>
<arg>-Xcopyable</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.0</version>
</plugin>
</plugins>
</configuration>
</execution>
</executions>
</plugin>
在 main.xsd 我有包含架构 - 如下所示:
<xsd:schema .... >
<xsd:include schemaLocation="includeMe.xsd"/>
<xsd:element name="Job">
.....
</xsd:element>
</xsd:schema>
includeMe.xsd 的内容:
<xsd:schema .... >
<xsd:element name="JobDef">
.....
</xsd:element>
</xsd:schema>
问题:即使 JAXB 正确生成了所有类(Job 和 JobDef),ObjectFactory 仍然只包含 main.xsd 中定义的创建方法。
问题:如何正确生成 ObjectFactory 以便所有生成的类的创建方法都在那里?
任何指针?
卡勒菲尔