相依性

Due to the different inception dates of individual Spring Data modules, most of them carry different major and minor version numbers. The easiest way to find compatible ones is to rely on the Spring Data Release Train BOM that we ship with the compatible versions defined. In a Maven project, you would declare this dependency in the <dependencyManagement /> section of your POM as follows

Using the Spring Data release train BOM
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.data</groupId>
      <artifactId>spring-data-bom</artifactId>
      <version>2024.1.0</version>
      <scope>import</scope>
      <type>pom</type>
    </dependency>
  </dependencies>
</dependencyManagement>

The current release train version is 2024.1.0. The train version uses calver with the pattern YYYY.MINOR.MICRO. The version name follows ${calver} for GA releases and service releases and the following pattern for all other versions: ${calver}-${modifier}, where modifier can be one of the following

  • SNAPSHOT: Current snapshots

  • M1, M2, and so on: Milestones

  • RC1, RC2, and so on: Release candidates

You can find a working example of using the BOMs in our Spring Data examples repository. With that in place, you can declare the Spring Data modules you would like to use without a version in the <dependencies /> block, as follows

Declaring a dependency to a Spring Data module such as JPA
<dependencies>
  <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
  </dependency>
<dependencies>

使用 Spring Boot 的相依性管理

Spring Boot 會為您選擇最新版本的 Spring Data 模組。如果您仍想升級到更新的版本,請將 spring-data-bom.version 屬性設定為您想要使用的列車版本和迭代

有關更多詳細資訊,請參閱 Spring Boot 的文件 (搜尋 "Spring Data Bom")。

Spring Framework

目前版本的 Spring Data 模組需要 Spring Framework 6.2.0 或更高版本。這些模組也可能適用於該次要版本的舊版錯誤修正版本。但是,強烈建議在該世代中使用最新版本。