Подтвердить что ты не робот

Конфликтные версии datanucleus enhancer в проекте движка Google Maven

У меня проблема с настройкой datanucleus enhancer для использования с проектом движка Google. Если я использую плагин 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)

Я не понимаю, почему datanucleus требовал maven для загрузки datanucleus-core-1.1.3.jar, поскольку это не упоминается в pom.xml

Я также не понимаю, почему регистрируется datanucleus-core-1.1.3.jar...

Любые идеи? Спасибо заранее...

4b9b3361

Ответ 1

Плагин DN M2 извлекает последние версии доступных баннеров DN, чтобы он выполнял свою работу (нет другого разумного способа сделать это, кроме использования последних). Вы хотите ограничить "ядро" другой версией, указав зависимость ядра от плагина или указав, что в вашем приложении

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

Ответ 2

К сожалению, ответ "скрыт" в комментариях:

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

Это сработало для меня!

Ответ 3

Я столкнулся с той же проблемой при тестировании архетипа плагина 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>

Ответ 4

После прочтения "" Как переопределить зависимость плагина в 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>

Ответ 5

очистка старой версии datanucleus от вашего локального репозитория maven и решение проблемы.

Ответ 6

Maven-datanucleus-plugin прекратил вытягивать последние версии доступного ядра датануклеуса с версии 3.1.1.

Проверьте различия между файлами POM для Maven-datanucleus-plugin 3.1.1 (http://repo1.maven.org/maven2/org/datanucleus/maven-datanucleus-plugin/3.1.1/maven-datanucleus-plugin-3.1.1.pom) и 3.1.0-release (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.