为Google App Engine运行Maven构建时,出现构建错误:


  org.apache.maven.plugin.MojoExecutionException:DataNucleus工具
  org.datanucleus.enhancer.DataNucleusEnhancer以非null退出
  退出代码。


我正在尝试让Datanucleus与JDO和数据增强器一起使用。

我已按照说明进行操作,并将以下内容包含在我的pom.xml中:

  <plugin>
  <groupId>org.datanucleus</groupId>
  <artifactId>datanucleus-maven-plugin</artifactId>
        <version>5.0.0-release</version>
        <configuration>
          <persistenceUnitName>transactions-optional</persistenceUnitName>
            <verbose>true</verbose>
        </configuration>
       <executions>
            <execution>
                <phase>process-classes</phase>
                <goals>
                    <goal>enhance</goal>
                </goals>
            </execution>
        </executions>
      <dependencies>
      <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-core</artifactId>
        <version>3.1.0-release</version>
        <scope>runtime</scope>
      </dependency>
          <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jdo</artifactId>
            <version>3.1.0-release</version>
          </dependency>
        </dependencies>
    </plugin>


顺便说一句,这在Java 7上运行良好,并且没有构建工具。这是Java 8和Maven的新项目。当我运行mvn -X datanucleus:enhance时遇到相同的错误

被困了几天,并尝试了插件配置的各种迭代以及有关Stack Overflow的建议,但没有运气。任何援助将不胜感激。

最佳答案

看,即使我几天都遇到同样的问题,终于意识到小事情会造成大麻烦。首先,请参考以下链接:
http://www.datanucleus.org/products/accessplatform_3_0/jdo/maven.html

并使用正确的提及版本。问题是,您不能仅使用任何版本的jdo-api,datanucleus-api-jdo和datanucleus-core。这些必须同步。请参阅下面我正在使用:

<dependency>
        <groupId>javax.jdo</groupId>
        <artifactId>jdo-api</artifactId>
        <version>3.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-api-jdo</artifactId>
        <version>3.1.3</version>
    </dependency>
    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-api-jpa</artifactId>
        <version>3.1.3</version>
    </dependency>
    <dependency>
     <groupId>org.apache.geronimo.specs</groupId>
     <artifactId>geronimo-jpa_2.0_spec</artifactId>
     <version>1.0</version>
   </dependency>
   <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-core</artifactId>
        <version>3.1.3</version>
    </dependency>
    <dependency>
        <groupId>com.google.appengine.orm</groupId>
        <artifactId>datanucleus-appengine</artifactId>
        <version>2.1.2</version>
    </dependency>


和插件为:

<plugin>
            <groupId>com.google.cloud.tools</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>${appengine.maven.plugin.version}</version>
        </plugin>
        <plugin>
            <groupId>org.datanucleus</groupId>
            <artifactId>maven-datanucleus-plugin</artifactId>
            <version>3.2.0-m1</version>
            <configuration>
                <api>JDO</api>
                <log4jConfiguration>${basedir}/src/main/resources/META-INF/log4j.properties</log4jConfiguration>
                <props>${basedir}/datanucleus.properties</props>
                <verbose>true</verbose>
                <enhancerName>ASM</enhancerName>
                <fork>false</fork>
            </configuration>
            <executions>
                <execution>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>enhance</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.datanucleus</groupId>
                    <artifactId>datanucleus-core</artifactId>
                    <version>3.1.3</version>
                </dependency>
            </dependencies>
        </plugin>


再检查几张,确保pom中包含以下内容:

<prerequisites>
    <maven>3.0</maven>
</prerequisites>


最后,运行maven安装,看看增强器是否有效!日志如下:

 DataNucleus Enhancer (version 3.1.1) : Enhancement of classes.
 DataNucleus Enhancer completed with success for 2 classes. Timings : input=594 ms, enhance=46 ms, total=640 ms. Consult the log for full details
 [INFO]
 [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) --


我刚刚在进行了新的迁移更改后进行了部署,它支持生产中的旧数据存储值,并且就像一个魅力一样!希望对您有所帮助!

10-08 15:25