3

如果我运行,我的带有 JAXB2 插件的 Maven 项目可以正常工作

mvn clean install

但是如果我跳过清理并运行它总是会失败

mvn install

在这种情况下,生成的类不会再次生成,这是正确的:

[INFO] No changes detected in schema or binding files - skipping JAXB generation.

但是后来我得到一个编译错误,当编译这个 Maven 项目中的其余静态 Java 源时,找不到生成的类和包:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project [...]: Compilation failure: Compilation failure:
[ERROR] [...] package [...] does not exist
[ERROR] [... ]cannot find symbol

这是我的 pom.xml 的相关部分(其余的只是依赖项):

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>
<executions>                    
    <execution>
        <id>xjc-core</id>
        <goals>
            <goal>xjc</goal>
        </goals>
        <configuration>
            <sources>
                <source>${project.basedir}/src/main/xsd/core</source>
            </sources>
            <packageName>com.example.core</packageName>
            <clearOutputDir>false</clearOutputDir>
        </configuration>
    </execution>
    <!-- ... and more <execution>  -->
</executions>               

我是否正确,唯一的解决方案是将静态源和生成的源分离到不同的 Maven 模块中?或者还有其他方法吗?

4

1 回答 1

3

jaxb2-maven-plugin v2.2 https://github.com/mojohaus/jaxb2-maven-plugin/issues/35中有一个错误。此错误已在 v2.3 中修复

于 2016-10-05T15:15:14.657 回答