我正在尝试使用maven为GoogleAppEngine构建我的应用程序。我已经在我的pom中添加了以下内容,这应该在构建后“增强”我的课程,如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,所以我选择使用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,所以除非应用程序引擎库需要它,否则我不确定为什么会收到此消息。
答案 0 :(得分:11)
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
奇怪的是,DataNucleus Maven存储库中的jdo2-api-2.3-ec.jar
( 在插件的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。