依賴項
由於各個 Spring Data 模組的啟動日期不同,大多數模組都帶有不同的主版本號和次版本號。查詢相容版本的最簡單方法是依賴我們隨相容版本一起釋出的 Spring Data Release Train BOM。在 Maven 專案中,您可以在 POM 的 <dependencyManagement /> 部分中宣告此依賴項,如下所示
使用 Spring Data 釋出列車 BOM
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-bom</artifactId>
<version>2025.1.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
當前的釋出列車版本是 2025.1.0。列車版本使用帶有 YYYY.MINOR.MICRO 模式的 calver。對於 GA 版本和服務版本,版本名稱遵循 ${calver},對於所有其他版本,遵循以下模式:${calver}-${modifier},其中 modifier 可以是以下之一
-
SNAPSHOT:當前快照 -
M1、M2等:里程碑 -
RC1、RC2等:釋出候選版本
您可以在我們的 Spring Data 示例儲存庫 中找到使用 BOM 的工作示例。有了這個,您可以在 <dependencies /> 塊中宣告您希望使用的 Spring Data 模組,而無需版本,如下所示
宣告對 Spring Data 模組(如 JPA)的依賴
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependencies>