2017-04-18 42 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