5

Maven を使用して GoogleAppEngine 用のアプリケーションを構築しようとしています。DataNucleus のドキュメントで提案されているように、ビルド後にクラスを「強化」する必要がある pom に以下を追加しました。

<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 を使用することにしました。(GAE にアップロードする前に) を使用してプロジェクトをビルドしようとするとmvn clean package、次の出力が得られます。

[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 を参照していないため、アプリ エンジン ライブラリで必要とされない限り、なぜこのメッセージが表示されるのかわかりません。

4

1 に答える 1

11

DataNucleus Maven プラグインには、ここに記載されているように (JPA の場合でも) JDO2 API JAR が必要であり、トレースで報告されています。

  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 リポジトリ (プラグインのPOMで宣言されている)にあり、Mavenトレースで確認できるようにこのリポジトリをチェックしていることです。jdo2-api-2.3-ec.jar

更新:わかりました、これ間違いなく奇妙で、ビルドが正確に失敗する理由がわかりません (依存関係の範囲に問題がある可能性があります)。回避策として、プラグインで 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 がダウンロードされます。

于 2010-04-03T15:15:10.823 に答える