2012-06-28 88 views
2

這是我正在運行的Roo腳本。在終端和STS中使用來自shell的spring-roo-1.2.2.RELEASE版本。Google App Engine與Spring Roo

persistence setup --provider DATANUCLEUS --database GOOGLE_APP_ENGINE --applicationId roo-gae 

entity jpa --class ~.domain.Wheel --testAutomatically 
field string --fieldName code --notNull --unique 

entity jpa --class ~.domain.Car --testAutomatically 
field string --fieldName name --notNull --unique 
field string --fieldName color --notNull 
field reference --fieldName wheel --type ~.domain.Wheel --notNull 

perform tests 

我不作該項目的任何手動更改,但執行測試失敗,此消息:

[ERROR] Failed to execute goal org.datanucleus:maven-datanucleus-plugin:3.0.2:enhance (default) on project test: Error executing DataNucleus tool org.datanucleus.enhancer.DataNucleusEnhancer: InvocationTargetException: Plugin (Bundle) "org.datanucleus.enhancer" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/home/timh/.m2/repository/org/datanucleus/datanucleus-enhancer/3.1.0-m1/datanucleus-enhancer-3.1.0-m1.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/home/timh/.m2/repository/org/datanucleus/datanucleus-enhancer/3.0.1/datanucleus-enhancer-3.0.1.jar." -> [Help 1] 
[ERROR] .Car roo> 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] .Car roo> 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 

我看到DataNucleus將-增強-3.0.1.jar在類路徑上,但我認爲這個插件正在下載datanucleus-enhancer-3.1.0-m1.jar。有沒有人知道這個問題的解決方案或解決方法?

回答

2

這可以通過在您的pom.xml中的maven-datanucleus-plugin的依賴項下添加以下內容來手動指定datanucleus增強器插件版本來糾正。

<dependency> 
<groupId>org.datanucleus</groupId> 
<artifactId>datanucleus-enhancer</artifactId> 
<version>3.1.0-m2</version> 
</dependency> 

你最終的maven-dataanucleus-插件配置會出現如下圖所示一旦其加入。

<plugin> 
<groupId>org.datanucleus</groupId> 
<artifactId>maven-datanucleus-plugin</artifactId> 
<version>3.0.2</version> 
<configuration> 
     <fork>false</fork> 
     <log4jConfiguration>${basedir}/src/main/resources/log4j.properties</log4jConfiguration> 
     <mappingIncludes>**/*.class</mappingIncludes> 
     <verbose>true</verbose> 
     <enhancerName>ASM</enhancerName> 
     <api>JPA</api> 
    <mappingExcludes>**/CustomRequestFactoryServlet.class, **/GaeAuthFilter.class</mappingExcludes> 
</configuration> 
<executions> 
    <execution> 
     <phase>compile</phase> 
     <goals> 
      <goal>enhance</goal> 
     </goals> 
    </execution> 
</executions> 
<dependencies> 
    <dependency> 
     <groupId>org.datanucleus</groupId> 
     <artifactId>datanucleus-core</artifactId> 
     <version>3.0.10</version> 
    </dependency> 
    <dependency> 
     <groupId>org.datanucleus</groupId> 
     <artifactId>datanucleus-enhancer</artifactId> 
     <version>3.1.0-m2</version> 
    </dependency> 
    <dependency> 
     <groupId>org.datanucleus</groupId> 
     <artifactId>datanucleus-api-jpa</artifactId> 
     <version>3.0.9</version> 
    </dependency> 
</dependencies> 
</plugin> 

乾杯。

1

我通過將「運行時」的作用域添加到datanucleus-core maven dependency中來糾正了此問題。

+0

你爲什麼不使用範圍'測試'? – bhagyas

+0

因爲在運行時需要它,所以我認爲在編譯期間插件提供了另一個「增強器」類來增強Datanucleus類,並且它與被這個jar所利用的類相沖突。 – Mouscellaneous