我的目标是使用maven-jaxb2-plugin从XSD生成java代码,特别是从3个独立的模式生成。我面临的问题是所有模式都依赖于公共模式,并且生成了相同的类三次。
我正在使用的pom部分如下所示:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>xjc-a</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<packageName>com.a</packageName>
<schemaDirectory>src/main/resources/a</schemaDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
<execution>
<id>xjc-b</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<packageName>com.b</packageName>
<schemaDirectory>src/main/resources/b</schemaDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
<execution>
<id>xjc-c</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<packageName>com.c</packageName>
<schemaDirectory>src/main/resources/c</schemaDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>
</plugin>
模式a,b,c都包含一个通用模式,比如d。当生成源时,在每个包中生成来自d的类,我想要做的是将公共类分解为单独的包。 感谢