2017-04-18 99 views
0

我正在mvn clean test
行家3.3.9
的Java 1.8.0_45
TestNG的6.8.5
和我的春天版本的工作是4.0.4.RELEASE
但出現以下錯誤。MVN測試不與Maven 3.3.9和Java 1.8.0_45

[ERROR] springTestContextPrepareTestInstance(com.inn.app17apr02.db.TestAuditDb) Time elapsed: 1.205 s <<< FAILURE! java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [/home/ist/apache-tomcat-7.0.59/webapps/REPO/app17apr02/app17apr02/1.0/app17apr02/target/classes/applicationContext/application.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index; Caused by: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;

我搜查了很多,並嘗試了不同的組合和排列,但仍然沒有成功。 以下是在POM我的插件進入

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.20</version> 
    <configuration> 
     <properties> 
      <property> 
       <name>usedefaultlisteners</name> 
       <value>false</value> 
      </property> 
      <property> 
       <name>listener</name> 
       <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value> 
      </property> 
      <property> 
       <name>testname</name> 
       <value>${project.name} TestNG tests reports</value> 
      </property> 
     </properties> 
     <systemProperties> 
      <property> 
       <name>org.uncommons.reportng.title</name> 
       <value>${project.name} TestNG Report</value> 
      </property> 
      <property> 
       <name>org.uncommons.reportng.stylesheet</name> 
       <value>/home/ist/apache-tomcat-7.0.59/webapps/REPO/app17apr02/app17apr02/1.0/app17apr02/headstart/artifacts/custom.css</value> 
      </property> 
      <property> 
       <name>org.uncommons.reportng.coverage-report</name> 
       <value>https://www.google.co.in</value> 
      </property> 
     </systemProperties> 
     <workingDirectory>target/</workingDirectory> 
     <reportsDirectory>/home/ist/apache-tomcat-7.0.59/webapps/REPO/app17apr02/app17apr02/1.0/app17apr02/headstart/sartifacts/surefire-reports</reportsDirectory> 
     <classpathDependencyExcludes> 
      <classpathDependencyExclude>org.apache.tika:tika-app</classpathDependencyExclude> 
     </classpathDependencyExcludes> 
     <forkCount>3</forkCount> 
     <reuseForks>true</reuseForks> 
     <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine> 
    </configuration> 
    <dependencies> 
     <dependency> 
      <groupId>org.hibernate.javax.persistence</groupId> 
      <artifactId>hibernate-jpa-2.1-api</artifactId> 
      <version>1.0.0.Final</version> 
     </dependency> 
    </dependencies> 
</plugin> 

請讓我知道,如果需要更多的信息。
我已經嘗試過不同的JAP 2.x罐子,因此許多答案都表示這是JPA jar的問題,並嘗試了不同的surefire版本,如2.18.x,2.19.x.
任何幫助將不勝感激。

+0

也試圖與Maven 3.0.3和3.5.0,但相同的結果,並且工作正常使用Maven 2.2.1 – DnA

回答

1

在版本2.1中添加了表#索引()方法,因此您使用的jar是正確的。 在類路徑中可能還會添加其他一些jar,這些jar也有@Table註釋,例如persistence-api-1.0.jar或其他一些jar。檢查你的班級路徑,並刪除/排除這些罐子。

您可能需要的Hibernate的EntityManager依賴

<dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-entitymanager</artifactId> 
     <version>5.1.0.Final</version> 
     <scope>runtime</scope> 
    </dependency> 
+0

感謝您的答覆我已經檢查了使用mvn依賴性:樹類路徑上沒有其他持久性jar,並且使用與上面相同的依賴性 – DnA

+0

然後請嘗試添加hibernate-entitymanager,並檢查它是否可用。 – vsbehere

+0

最後它的工作原理是openjpa - 所有的jar都是衝突的。 – DnA