【问题标题】:Maven "clean install site" fails for JPA Metamodel generated classesJPA Metamodel 生成的类的 Maven“全新安装站点”失败
【发布时间】:2015-08-20 18:44:45
【问题描述】:

我正在开发一个使用 maven-processor-plugin 生成 JPA 元模型的 JPA/Hibernate 应用程序

    <plugin>
        <groupId>org.bsc.maven</groupId>
        <artifactId>maven-processor-plugin</artifactId>
        <version>2.2.4</version>
        <executions>
           <execution>
              <id>process</id>
              <goals>
                <goal>process</goal>
              </goals>
              <phase>generate-sources</phase>
           </execution>
        </executions>
        <dependencies>
             <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-jpamodelgen</artifactId>
                  <version>4.3.5.Final</version>
             </dependency>
        </dependencies>
     </plugin>

当我尝试执行 mvn clean install site 时,它会失败,并在 Metamodel 类上出现以下错误”

  error: Person_ is already defined as object Person_

但是当我执行 mvn clean install 然后 mvn site 时,它工作正常。

对此的任何帮助将不胜感激。谢谢。

【问题讨论】:

  • 您能否分享mvn clean install site -X 的输出以及您的整个pom.xml 文件。
  • 这是我的 pom.xml - pastebin.com/vu1gvmSQ
  • 还有一个调试输出会很棒 mvn clean install site -X

标签: java hibernate maven jpa


【解决方案1】:

我已经解决了这个问题。它需要以下插件才能工作。

        <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>${project.basedir}/target/generated-sources/</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

我还在我正在使用的 ma​​ven-processor-plugin 中添加了以下配置。

            <configuration>
                <outputDirectory>${project.basedir}/target/generated-sources/</outputDirectory>
            </configuration>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-28
    • 1970-01-01
    • 1970-01-01
    • 2019-01-10
    • 2014-04-13
    • 1970-01-01
    相关资源
    最近更新 更多