SpringDataJPA单元测试报错:Could not open JPA EntityManager for transaction;
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
今天在学习spring data JPA多表操作时,运行单元测试报错:
解决方案:
这是因为Hibernate版本不兼容问题,原来是用5.2.17的:
然后,我换成了5.0.7版本的:
最终,运行成功!