如何找到Hibernate和Spring的Maven依赖兼容性?

How to find the Maven dependency compatibility of Hibernate and Spring?

我遇到依赖相关问题的困难,例如:

我在 4.1.1.RELEASE 版本中创建了一个 spring 项目。现在我想为 spring 版本 4.1.1.RELEASE.

使用休眠依赖

但是哪个版本的hibernate依赖与spring以上版本兼容?有没有兼容性检查或其他网站?请帮助我

我建议使用 Spring Boot. (我并不是说你应该使用Spring-Boot,只是使用同一套dependencies/versions)。

Spring Boot 有某种 ob BOM-depencency,其中包含依赖项:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>1.2.3.RELEASE</version>
</dependency>

spring-boot 的当前版本:1.2.3.RELEASE 使用 Spring 4.1.6.RELEASE,因此您可能必须搜索一个靴子有点旧。

甚至 Spring-Boot 1.2.0.RELEASE 使用 Spring 4.1.3.RELEASE - 所以你更新到 Spring >= 4.1.3。或者你忽略这个版本不匹配。

在你选择了正确的Spring-启动版本之后:你可以检查这个文件并搜索你需要的版本号,或者你将它导入到你的pom.xml,然后在你的 hibernate-dependency>

中省略明确的 version 属性
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.2.3.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement> 
...
<dependencies>
    <dependency>     
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <!-- version is taken from the bom -->
    </dependency>
</dependencies>

你可以简单地 运行:

mvn dependency:tree

然后查找从 spring 模块继承的 org.hiberante 依赖项。这就是您可以判断哪个 Spring 版本使用特定 Hibernate 依赖项的方法。