Spring 引导和 Spring 数据 Jpa 版本兼容性

Spring Boot and Spring Data Jpa versions compatiblity

我正在使用最新的(截至撰写本文时)Spring-Boot-starter-data-jpa(版本 1.2.6.RELEASE)。我发现它实际上使用 Spring-data-jpa 版本 1.7.3.RELEASE,这大大落后于最新版本 (1.9)。

是否支持升级单个依赖项(例如 Spring-data-jpa)的方法?如果我自己这样做,例如,通过声明对所需更新版本的直接依赖(可能只是覆盖版本属性),你们预见到任何副作用吗?

我之所以这样做是因为我需要在这个注解中使用一个特殊的参数:@EnableJpaRepositories(repositoryBaseClass = JpaRepositoryWithI18n.class)

在提供的 1.7.3 jpa 库中不可用。

任何解决方法也将不胜感激。

谢谢

编辑: 我测试了以下两种方式:1)声明对 Spring-JPA-data 1.9.0 的直接依赖并将其从 spring-boot-starter-data-jpa 中排除 2)升级 Spring-boot-web-starter 到 1.3.0m5

2) 对我来说效果很好。这也是dunni的回答所建议的。

我没有测试 Andi 的答案,因为这是一个新项目,我们可以轻松升级整个 spring 引导并对其进行回归测试,而不必太担心副作用。

但我可以看出 Andi 的回答比 1) 更简单。更重要的是,它展示了如何独立升级其他依赖项——只需覆盖父 pom.xml 中的版本即可。

谢谢

Spring 启动测试用例不包含较新版本,这在这方面不受支持。因此您的应用程序可能适用于较新的版本,但可能会出现一些错误。对于次要版本,与主要版本升级相比,它更有可能毫无问题地工作。您还可以升级 Spring Boot 到 1.3.0.M5(但是请注意,这是一个里程碑版本,尚未发布)。

Spring Data JPA 1.9 是 Spring Data Gosling 发布系列的一部分。作为 described in the Gosling announcement,您可以将它与 Spring Boot 1.2:

一起使用

To upgrade to the new release train use the BOM we ship as described in our examples repository and configure its version to Gosling-RELEASE. If you’re using Spring Boot, upgrading to the release train is as easy as setting the Maven property spring-data-releasetrain.version to that version. Note, that to use Spring Data REST with Boot 1.2, you also need to upgrade to Spring HATEOAS 0.19.0.RELEASE (by setting the spring-hateoas.version property) and Jackson 2.5 or better (current 2.6.1 preferred, via the jackson.version property).

简而言之,将其添加到您的 pom 中:

<properties>
    <spring-data-releasetrain.version>Gosling-RELEASE</spring-data-releasetrain.version>
</properties>