我正在尝试使用jaxb-maven插件使用JAXB将多个XSD转换为不同包中的POJO。我已将其设置为使用多个执行块,第一个执行块执行,然后我收到一条消息:在架构或绑定文件中未检测到任何更改
这是我的pom.xml的摘录:
...
<build>
<pluginManagement>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
</plugin>
</pluginManagement>
<plugins>
<!-- JAXB GENERATOR PLUGIN -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>Application0</id>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>src/main/webapp/WEB-INF/xsd/version1</schemaDirectory>
<packageName>za.co.mycee.application.model</packageName>
<outputDirectory>${basedir}/src/main/java/</outputDirectory>
<clearOutputDir>false</clearOutputDir>
<source>1.5</source>
<target>2.1</target>
<arguments>-no-header</arguments>
</configuration>
</execution>
<execution>
<id>Application1</id>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>src/main/webapp/WEB-INF/xsd/version1</schemaDirectory>
<packageName>za.co.mycee.application.model.version1</packageName>
<outputDirectory>${basedir}/src/main/java/</outputDirectory>
<clearOutputDir>false</clearOutputDir>
<source>1.5</source>
<target>2.1</target>
<arguments>-no-header</arguments>
</configuration>
</execution>
<execution>
<id>Application2</id>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>src/main/webapp/WEB-INF/xsd/version2</schemaDirectory>
<packageName>za.co.mycee.application.model.version2</packageName>
<outputDirectory>${basedir}/src/main/java/</outputDirectory>
<clearOutputDir>false</clearOutputDir>
<source>1.5</source>
<target>2.1</target>
<arguments>-no-header</arguments>
</configuration>
</execution>
</executions>
</plugin>
...
</build>
....
这是我收到的错误消息:
[INFO] --- jaxb2-maven-plugin:1.5:xjc (Application) @ mycee-application ---
[INFO] Generating source...
[INFO] parsing a schema...
[INFO] compiling a schema...
[INFO] za/co/mycee/application/model/AddressType.java
[INFO] ...
[INFO] za/co/mycee/application/model/package-info.java
[INFO]
[INFO] --- jaxb2-maven-plugin:1.5:xjc (Application1) @ mycee-application ---
[INFO] No changes detected in schema or binding files - skipping source generation.
[INFO]
[INFO] --- jaxb2-maven-plugin:1.5:xjc (Application2) @ mycee-application ---
[INFO] No changes detected in schema or binding files - skipping source generation.
如果我交换执行块,第一个总是执行,我得到剩余两个块的相同消息。
有关如何解决此问题的任何想法?
答案 0 :(得分:9)
通过升级到版本1.6
来修复它<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
</plugin>
和
<!-- JAXB GENERATOR PLUGIN -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
....
在版本1.6中修复,在版本1.5中,所有执行块都使用相同的staleFile:http://jira.codehaus.org/browse/MJAXB-8