spring boot配置spring-data-jpa的时候报错CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NoSuchMethodError

F:\java\jdk8\jdk1.8.0_211\bin\java.exe -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:D:\软件\IntelliJ IDEA 2019.2.2\lib\idea_rt.jar=7513:D:\软件\IntelliJ IDEA 2019.2.2\bin" -Dfile.encoding=UTF-8 -classpath "D:\软件\IntelliJ IDEA 2019.2.2\lib\idea_rt.jar;D:\软件\IntelliJ IDEA 2019.2.2\plugins\junit\lib\junit-rt.jar;D:\软件\IntelliJ IDEA 2019.2.2\plugins\junit\lib\junit5-rt.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\charsets.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\deploy.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\access-bridge-64.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\cldrdata.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\dnsns.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\jaccess.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\jfxrt.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\localedata.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\nashorn.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\sunec.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\sunjce_provider.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\sunmscapi.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\sunpkcs11.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\ext\zipfs.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\javaws.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\jce.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\jfr.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\jfxswt.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\jsse.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\management-agent.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\plugin.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\resources.jar;F:\java\jdk8\jdk1.8.0_211\jre\lib\rt.jar;D:\Project\frame\springdata\jpaday2\target\test-classes;D:\Project\frame\springdata\jpaday2\target\classes;F:\my_java\maven_repository\junit\junit\4.9\junit-4.9.jar;F:\my_java\maven_repository\org\hamcrest\hamcrest-core\1.1\hamcrest-core-1.1.jar;F:\my_java\maven_repository\org\aspectj\aspectjweaver\1.6.8\aspectjweaver-1.6.8.jar;F:\my_java\maven_repository\org\springframework\spring-aop\4.2.4.RELEASE\spring-aop-4.2.4.RELEASE.jar;F:\my_java\maven_repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;F:\my_java\maven_repository\org\springframework\spring-context\4.2.4.RELEASE\spring-context-4.2.4.RELEASE.jar;F:\my_java\maven_repository\org\springframework\spring-expression\4.2.4.RELEASE\spring-expression-4.2.4.RELEASE.jar;F:\my_java\maven_repository\org\springframework\spring-context-support\4.2.4.RELEASE\spring-context-support-4.2.4.RELEASE.jar;F:\my_java\maven_repository\org\springframework\spring-orm\4.2.4.RELEASE\spring-orm-4.2.4.RELEASE.jar;F:\my_java\maven_repository\org\springframework\spring-jdbc\4.2.4.RELEASE\spring-jdbc-4.2.4.RELEASE.jar;F:\my_java\maven_repository\org\springframework\spring-tx\4.2.4.RELEASE\spring-tx-4.2.4.RELEASE.jar;F:\my_java\maven_repository\org\springframework\spring-beans\4.2.4.RELEASE\spring-beans-4.2.4.RELEASE.jar;F:\my_java\maven_repository\org\springframework\spring-core\4.2.4.RELEASE\spring-core-4.2.4.RELEASE.jar;F:\my_java\maven_repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;F:\my_java\maven_repository\org\hibernate\hibernate-core\5.4.4.Final\hibernate-core-5.4.4.Final.jar;F:\my_java\maven_repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;F:\my_java\maven_repository\javax\persistence\javax.persistence-api\2.2\javax.persistence-api-2.2.jar;F:\my_java\maven_repository\org\javassist\javassist\3.24.0-GA\javassist-3.24.0-GA.jar;F:\my_java\maven_repository\net\bytebuddy\byte-buddy\1.9.11\byte-buddy-1.9.11.jar;F:\my_java\maven_repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;F:\my_java\maven_repository\org\jboss\spec\javax\transaction\jboss-transaction-api_1.2_spec\1.1.1.Final\jboss-transaction-api_1.2_spec-1.1.1.Final.jar;F:\my_java\maven_repository\org\jboss\jandex\2.0.5.Final\jandex-2.0.5.Final.jar;F:\my_java\maven_repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;F:\my_java\maven_repository\javax\activation\javax.activation-api\1.2.0\javax.activation-api-1.2.0.jar;F:\my_java\maven_repository\org\dom4j\dom4j\2.1.1\dom4j-2.1.1.jar;F:\my_java\maven_repository\org\hibernate\common\hibernate-commons-annotations\5.1.0.Final\hibernate-commons-annotations-5.1.0.Final.jar;F:\my_java\maven_repository\javax\xml\bind\jaxb-api\2.3.1\jaxb-api-2.3.1.jar;F:\my_java\maven_repository\org\glassfish\jaxb\jaxb-runtime\2.3.1\jaxb-runtime-2.3.1.jar;F:\my_java\maven_repository\org\glassfish\jaxb\txw2\2.3.1\txw2-2.3.1.jar;F:\my_java\maven_repository\com\sun\istack\istack-commons-runtime\3.0.7\istack-commons-runtime-3.0.7.jar;F:\my_java\maven_repository\org\jvnet\staxex\stax-ex\1.8\stax-ex-1.8.jar;F:\my_java\maven_repository\com\sun\xml\fastinfoset\FastInfoset\1.2.15\FastInfoset-1.2.15.jar;F:\my_java\maven_repository\org\hibernate\hibernate-entitymanager\5.4.4.Final\hibernate-entitymanager-5.4.4.Final.jar;F:\my_java\maven_repository\org\hibernate\hibernate-validator\5.2.1.Final\hibernate-validator-5.2.1.Final.jar;F:\my_java\maven_repository\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;F:\my_java\maven_repository\c3p0\c3p0\0.9.1.2\c3p0-0.9.1.2.jar;F:\my_java\maven_repository\log4j\log4j\1.2.12\log4j-1.2.12.jar;F:\my_java\maven_repository\org\slf4j\slf4j-api\1.6.6\slf4j-api-1.6.6.jar;F:\my_java\maven_repository\org\slf4j\slf4j-log4j12\1.6.6\slf4j-log4j12-1.6.6.jar;F:\my_java\maven_repository\mysql\mysql-connector-java\8.0.17\mysql-connector-java-8.0.17.jar;F:\my_java\maven_repository\com\google\protobuf\protobuf-java\3.6.1\protobuf-java-3.6.1.jar;F:\my_java\maven_repository\org\springframework\data\spring-data-jpa\1.9.0.RELEASE\spring-data-jpa-1.9.0.RELEASE.jar;F:\my_java\maven_repository\org\springframework\data\spring-data-commons\1.11.0.RELEASE\spring-data-commons-1.11.0.RELEASE.jar;F:\my_java\maven_repository\org\aspectj\aspectjrt\1.8.6\aspectjrt-1.8.6.jar;F:\my_java\maven_repository\org\slf4j\jcl-over-slf4j\1.7.12\jcl-over-slf4j-1.7.12.jar;F:\my_java\maven_repository\org\springframework\spring-test\4.2.4.RELEASE\spring-test-4.2.4.RELEASE.jar;F:\my_java\maven_repository\javax\el\javax.el-api\2.2.4\javax.el-api-2.2.4.jar;F:\my_java\maven_repository\org\glassfish\web\javax.el\2.2.4\javax.el-2.2.4.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 @w@C:\Users\ASUS\AppData\Local\Temp\idea_working_dirs_junit.tmp @C:\Users\ASUS\AppData\Local\Temp\idea_junit.tmp
log4j:WARN No appenders could be found for logger (org.springframework.test.context.junit4.SpringJUnit4ClassRunner).
log4j:WARN Please initialize the log4j system properly.




org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;

    at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:431)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:427)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:276)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
    at com.sun.proxy.$Proxy35.findOne(Unknown Source)
    at com.king.test.CustomerDaoTest.testFindOne(CustomerDaoTest.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:254)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:24)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.prepareFlushMode(HibernateJpaDialect.java:187)
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.beginTransaction(HibernateJpaDialect.java:173)
    at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:380)
    ... 50 more




Process finished with exit code -1

jar冲突问题

    <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>4.2.5.RELEASE</version>
        </dependency>

将spring-orm的jar包升为高版本问题解决

posted @ 2019-09-23 08:27  殇之弑梦  阅读(1316)  评论(0编辑  收藏  举报