google-app-engine - 为 GoogleAppEngine 构建 Maven,强制包含 JDO 库?

标签 google-app-engine maven-2 jpa jdo datanucleus

我正在尝试使用 Maven 为 GoogleAppEngine 构建我的应用程序。我已经将以下内容添加到我的 pom 中,它应该在构建后“增强”我的类(class),如 DataNucleus documentation 上的建议

<plugin>
                <groupId>org.datanucleus</groupId>
                <artifactId>maven-datanucleus-plugin</artifactId>
                <version>1.1.4</version>
                <configuration>
                    <log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
                    <verbose>true</verbose>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

根据 GoogleAppEngine 上的文档,您可以选择使用 JDO 或 JPA,我选择使用 JPA,因为我过去使用过它。当我尝试使用 mvn clean package 构建我的项目(在我上传到 GAE 之前)时,我得到以下输出

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) javax.jdo:jdo2-api:jar:2.3-ec

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=javax.jdo -DartifactId=jdo2-api -Dversion=2.3-ec -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=javax.jdo -DartifactId=jdo2-api -Dversion=2.3-ec -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) org.datanucleus:maven-datanucleus-plugin:maven-plugin:1.1.4
    2) javax.jdo:jdo2-api:jar:2.3-ec

----------
1 required artifact is missing.

for artifact: 
  org.datanucleus:maven-datanucleus-plugin:maven-plugin:1.1.4

from the specified remote repositories:
  __jpp_repo__ (file:///usr/share/maven2/repository),
  DN_M2_Repo (http://www.datanucleus.org/downloads/maven2/),
  central (http://repo1.maven.org/maven2)


[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Sat Apr 03 16:02:39 BST 2010
[INFO] Final Memory: 31M/258M
[INFO] ------------------------------------------------------------------------

我为什么会收到这样的错误有什么想法吗?我已经搜索了我的整个源代码,但我没有在任何地方引用 JDO,所以除非应用引擎库需要它,否则我不确定为什么会收到此消息。

最佳答案

DataNucleus Maven 插件需要 JDO2 API JAR(甚至对于 JPA),如记录here正如跟踪中所报告的那样:

  Path to dependency: 
    1) org.datanucleus:maven-datanucleus-plugin:maven-plugin:1.1.4
    2) javax.jdo:jdo2-api:jar:2.3-ec

奇怪的是jdo2-api-2.3-ec.jar 在 DataNucleus Maven 存储库中(在插件的 POM 中声明)并且 Maven 已经检查了这个存储库,如我们所见在痕迹中。

更新:好的,这绝对很奇怪,我不知道为什么构建会完全失败(可能是依赖范围的问题)。作为解决方法,将 JDO2 API JAR 声明为插件中的依赖项:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.datanucleus</groupId>
        <artifactId>maven-datanucleus-plugin</artifactId>
        <version>1.1.4</version>
        <configuration>
            <log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
            <verbose>true</verbose>
        </configuration>
        <executions>
            <execution>
                <phase>process-classes</phase>
                <goals>
                    <goal>enhance</goal>
                </goals>
            </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>javax.jdo</groupId>
            <artifactId>jdo2-api</artifactId>
            <version>2.3-ec</version>
            <scope>runtime</scope>
          </dependency>
        </dependencies>        
      </plugin>
      ...
    </plugins>
    ...
  </build>

</project>

声明此依赖项后,JAR 将被下载。

关于google-app-engine - 为 GoogleAppEngine 构建 Maven,强制包含 JDO 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2571619/

相关文章:

java - Google App Engine 上的 Stripes 问题

java - 如何使用 java-google-translate-text-to-speech api?

maven-2 - 为什么 IntelliJ 没有添加 Maven 目标?

java - 将使用 ManyToMany 关系的 SQL 查询转换为 JPQL 查询

java - 带有计数字段的 JPQL ManyToMany 查询

java - 将 Objectify 与 GAE 一起使用时 ObjectifyService 的 NoClassDefFoundError

android - 使用 Android + GAE Cloud Endpoints 搞乱字符编码

maven-2 - maven 发布插件 - wagon 因 ssh 身份验证失败,但 snapshort 和发布部署工作 - 嗯?

java - Google App Engine 1.3.1 JAR 在公开可用的 Maven 存储库中?

java - 在 JPA 中选择 OneToMany 关系的子级