Maven Google App Engine プロジェクト内の datanucleus エンハンサーのバージョンが競合する

StackOverflow https://stackoverflow.com/questions/877949

質問

Google App Engine プロジェクトで使用する datanucleus エンハンサーの設定で問題が発生しています。datanucleus eclipse プラグインを使用するとすべてがうまくいきますが、Maven プロジェクトでは奇妙なバージョン競合エラーが発生します。

私の POM には次の datanucleus 参照があります。

<dependency>
    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-core</artifactId>
    <version>1.1.0</version>
</dependency>

...

<plugin>
    <groupId>org.datanucleus</groupId>
    <artifactId>maven-datanucleus-plugin</artifactId>
    <version>1.1.0</version>
    <configuration>
        <mappingIncludes>**/*.class</mappingIncludes>
        <verbose>true</verbose>
        <enhancerName>ASM</enhancerName>
        <api>JDO</api>
    </configuration>
    <executions>
        <execution>
        <phase>compile</phase>
        <goals>
            <goal>enhance</goal>
        </goals>
        </execution>
    </executions>
</plugin>

プロジェクトをビルドしようとすると、次のエラーが表示されます。

Exception in thread "main" Plugin (Bundle) "org.datanucleus" is already registered. 
Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/Users/drome/.m2/repository/org/datanucleus/datanucleus-core/1.1.0/**datanucleus-core-1.1.0.jar**" is already registered, and you are trying to register an identical plugin located at URL "file:/Users/drome/.m2/repository/org/datanucleus/datanucleus-core/1.1.3/**datanucleus-core-1.1.3.jar**."
org.datanucleus.exceptions.NucleusException: Plugin (Bundle) "org.datanucleus" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/Users/drome/.m2/repository/org/datanucleus/datanucleus-core/1.1.0/datanucleus-core-1.1.0.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/Users/drome/.m2/repository/org/datanucleus/datanucleus-core/1.1.3/datanucleus-core-1.1.3.jar."
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:437)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:343)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensions(NonManagedPluginRegistry.java:227
)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensionPoints(NonManagedPluginRegistry.jav
a:159)
at org.datanucleus.plugin.PluginManager.registerExtensionPoints(PluginManager.java:82)
at org.datanucleus.OMFContext.(OMFContext.java:164)
at org.datanucleus.enhancer.DataNucleusEnhancer.(DataNucleusEnhancer.java:171)
at org.datanucleus.enhancer.DataNucleusEnhancer.(DataNucleusEnhancer.java:149)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1157)

これは pom.xml で参照されていないため、datanucleus が maven に datanucleus-core-1.1.3.jar をダウンロードする必要がある理由がわかりません。

また、datanucleus-core-1.1.3.jar が登録されている理由もわかりません...

何か案は?前もって感謝します...

役に立ちましたか?

解決

DN M2プラグインは、それがそのジョブを実行する必要が利用可能DNのjarファイルの最新バージョンで引っ張る(それは他の最新を使うよりも行うには、他の賢明な方法はありません)。あなたは、または指定することで、どちらかのコアのプラグインの依存関係を指定することで、異なるバージョンの「コア」を制限したいと、アプリケーション内の

<dependency>
    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-core</artifactId>
    <version>1.1.0</version>
    <scope>runtime</scope> 
</dependency>

他のヒント

残念ながら答えはコメントで「隠し」です。

<dependency>
    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-core</artifactId>
    <version>1.1.0</version>
    <scope>runtime</scope>
</dependency>

それは私のために働いた!

MavenのGAEプラグインの原型をテストしながら、

私は、同じ問題に遭遇します。

私はGAEランタイム推移依存関係に除外を追加することによって、それを修正

<!-- Google App Engine meta-package -->
        <dependency>
            <groupId>net.kindleit</groupId>
            <artifactId>gae-runtime</artifactId>
            <version>${gae.version}</version>
            <type>pom</type>
            <exclusions>
                <exclusion>
                    <groupId>com.google.appengine.orm</groupId>
                    <artifactId>datanucleus-core</artifactId>
                </exclusion>

            </exclusions>
        </dependency>

、その後、ランタイム依存関係として核コアを追加

<dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-core</artifactId>
            <version>${datanucleus-core.version}</version>
            <scope>runtime</scope>
            <exclusions>
                <exclusion>
                    <groupId>javax.transaction</groupId>
                    <artifactId>transaction-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

簡単なGAEプラグインのセクションを維持するようにます:

<plugin>
                <groupId>org.datanucleus</groupId>
                <artifactId>maven-datanucleus-plugin</artifactId>
                <version>${maven-datanucleus-plugin.version}</version>
                <configuration>
                    <!--
                        Make sure this path contains your persistent classes!
                    -->
                    <mappingIncludes>**/model/*.class</mappingIncludes>
                    <verbose>true</verbose>
                    <enhancerName>ASM</enhancerName>
                    <api>JDO</api>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

読んだ後、「 「Mavenののにプラグインの依存関係をオーバーライドする方法を、私はこの問題を解決する別の方法を発見しました。ここに私のPOMがあります:

<plugin>
  <groupId>org.datanucleus</groupId>
  <artifactId>maven-datanucleus-plugin</artifactId>
  <version>3.1.0-m3</version>
  <configuration>
    <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.0.4</version>
    </dependency>
  </dependencies>
</plugin>

また、問題を解決する、ローカルのMavenリポジトリからDataNucleusのあなたの古いバージョンをクリアします。

Maven-datanucleus-plugin は、バージョン 3.1.1 以降、利用可能な datanucleus-core の最新バージョンのプルを停止しました。

Maven-datanucleus-plugin 3.1.1 の POM ファイル間の違いを確認してください (http://repo1.maven.org/maven2/org/datanucleus/maven-datanucleus-plugin/3.1.1/maven-datanucleus-plugin-3.1.1.pom) および 3.1.0 リリース (http://mvnrepository.com/artifact/org.datanucleus/maven-datanucleus-plugin/3.1.0-release).

maven-datanucleus-plugin 3.1.1 の場合、datanucleus-core 依存関係のバージョン範囲は (3.0.99, 3.1.99) であり、maven-datanucleus-plugin 3.1.0-release の場合は (3.0.99, ) です。maven-datanucleus-plugin の古いバージョンでも不思議ではありませんが、datanucleus-core の最新バージョンが自動的に取り込まれます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top