maven-jaxb2-plugin用于多个模式的VS jaxb2-maven-plugin [英] maven-jaxb2-plugin VS jaxb2-maven-plugin for multiple schemas
问题描述
我有多个xsd架构,我想在相同文件夹 target / generated-sources / xjc
下解组到不同的包中。我尝试了两个插件,两者似乎都可以正常使用这两种配置但是在maven-jaxb2-plugin的情况下,eclipse插件会无限期地生成类(因为 forceRegenerate
= true )但是如果我没有指定forceRegenerate,当我运行 mvn clean package
我的配置是否有问题时,它根本不会生成第二和第三组类?
I have multiple xsd schemas that I want to unmarshall into different packages under the same folder target/generated-sources/xjc
. I tried both plugins and both seem to work fine with these 2 configurations but in case of maven-jaxb2-plugin the eclipse plugin keeps generating classes indefinitely (because of the forceRegenerate
= true) but if I don't specify forceRegenerate it won't generate the second and third set of classes at all when I run mvn clean package
Are there any issues with my configuration?
jaxb2-maven-plugin
jaxb2-maven-plugin
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>xjc-scores</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<packageName>com.generated.scores</packageName>
<schemaDirectory>src/main/resources/schemas/scores</schemaDirectory>
</configuration>
</execution>
<execution>
<id>xjc-videos-ramp</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<packageName>com.generated.ramp</packageName>
<schemaDirectory>src/main/resources/schemas/ramp</schemaDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
<execution>
<id>xjc-schedules</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<packageName>com.generated.schedules</packageName>
<schemaDirectory>src/main/resources/schemas/schedules</schemaDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>
<configuration>
</configuration>
</plugin>
maven-jaxb2-plugin
maven-jaxb2-plugin
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<id>xjc-scores</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatePackage>com.generated.scores</generatePackage>
<schemaDirectory>src/main/resources/schemas/scores</schemaDirectory>
<removeOldOutput>true</removeOldOutput>
</configuration>
</execution>
<execution>
<id>xjc-ramp</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatePackage>com.generated.ramp</generatePackage>
<schemaDirectory>src/main/resources/schemas/ramp</schemaDirectory>
<removeOldOutput>false</removeOldOutput>
</configuration>
</execution>
<execution>
<id>xjc-schedules</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatePackage>com.generated.schedules</generatePackage>
<schemaDirectory>src/main/resources/schemas/schedules</schemaDirectory>
<removeOldOutput>false</removeOldOutput>
</configuration>
</execution>
</executions>
<configuration>
<forceRegenerate>true</forceRegenerate>
</configuration>
</plugin>
和build-helper-maven-plugin配置:
and the build-helper-maven-plugin config:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/xjc</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-resource</id>
<phase>generate-sources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>target/generated-sources/xjc</directory>
<targetPath>target/classes</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
推荐答案
一般建议:用<$ c $指定你的包裹c> bindings.xjb 而不是在单独 generatePackage
s的不同执行中。
General advice: specify your packages in bindings.xjb
rather than in different executions with individual generatePackage
s.
<jxb:bindings schemaLocation="common1.xsd" node="/xsd:schema">
<jxb:schemaBindings>
<jxb:package name="mypackage.commonclasses"/>
</jxb:schemaBindings>
</jxb:bindings>
generatePackage
多重效果不佳架构。
请在
https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN
引用问题多个模式和Eclipse。我会看看它。
citing the problem with the multiple schemas and Eclipse. I'll take a look into it.
ps。免责声明:我是 maven-jaxb2-plugin
的作者。
ps. SO disclaimer: I'm the author of maven-jaxb2-plugin
.
这篇关于maven-jaxb2-plugin用于多个模式的VS jaxb2-maven-plugin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!