Dependencies
由于各个 Spring Data 模块的创立日期不同,因此它们中的大多数具有不同的主版本号和次版本号。查找兼容模块最简单的方法是依靠 Spring Data 发布火车 BOM,我们在其中定义了兼容版本。在 Maven 项目中,您应该按如下方式在 POM 的 <dependencyManagement />
部分声明此依赖项:
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:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-bom</artifactId>
<version>{releasetrainVersion}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
当前发行版版本是`{releasetrainVersion}`。火车版本使用 calver与模式`YYYY.MINOR.MICRO`。GA 版本和服务版本遵循 ${calver}`命名,其他所有版本的命名模式为:
${calver}-${modifier}`,其中 `modifier`可以是以下之一:
The current release train version is {releasetrainVersion}
. 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
您可以在我们的 Spring Data examples repository中找到使用 BOM 的工作示例。通过这样做,您可以在`<dependencies />`块中声明您想要使用的 Spring Data 模块,而无需输入版本,如下所示:
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:
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependencies>
Dependency Management with Spring Boot
Spring Boot 会为您选择 Spring Data 模块的最新版本。如果您仍希望升级到较新版本,请将 spring-data-bom.version
属性设置为您希望使用的 [火车版本和迭代,dependencies.train-version]。
Spring Boot selects a recent version of the Spring Data modules for you. If you still want to upgrade to a newer version,
set the spring-data-bom.version
property to the dependencies.train-version
you would like to use.
有关详细信息,请参见 Spring Boot 的 documentation(搜索“Spring Data Bom”)。
See Spring Boot’s documentation (search for "Spring Data Bom") for more details.
Spring Framework
当前版本的 Spring Data 模块要求 Spring Framework {springVersion} 或更高版本。这些模块还可能与该次要版本较旧的错误修复版本一起使用。但是,强烈建议使用该代中的最新版本。
The current version of Spring Data modules require Spring Framework {springVersion} or better. The modules might also work with an older bugfix version of that minor version. However, using the most recent version within that generation is highly recommended.