在编写java项目时,遇上报如下错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.<init>(PersistenceAnnotationBeanPostProcessor.java:665)
The following method did not exist:
javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType;
The method's class, javax.persistence.PersistenceContext, is available from the following locations:
jar:file:/E:/Tomcat%e5%ae%89%e8%a3%85/sprboot-mysql/lib/javax.persistence.jar!/javax/persistence/PersistenceContext.class
jar:file:/C:/Users/13652/.m2/repository/javax/persistence/javax.persistence-api/2.2/javax.persistence-api-2.2.jar!/javax/persistence/PersistenceContext.class
It was loaded from the following location:
file:/E:/Tomcat%e5%ae%89%e8%a3%85/sprboot-mysql/lib/javax.persistence.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.PersistenceContext
解决方法:删除其选择使用的重复了的jar包,一切正常。