Spring 4.3.2& hibernate 5.2.1:NosuchMethod错误

时间:2016-08-08 16:28:28

标签: mysql spring hibernate spring-mvc pom.xml

所以我有这个pom.xml:

<dependencies>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>4.3.2.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>5.3.0.Alpha1</version>
</dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.37</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>1.10.1.RELEASE</version>
    </dependency>

我仍然会收到此错误:

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)
... 52 common frames omitted

我搜索here并将其标记为已解决。也许不是!

任何解决方案? 感谢

1 个答案:

答案 0 :(得分:1)

如果有人遇到同样的问题:

问题是 spring-data-jpa 中的罐子是&#39; OLD &#39; &#39;所以你需要自己更新到最后一个版本 4.2.3 (在我的响应时间)或者只是排除在你的 POM.XML