有没有一种简单的方法来使用不同的 Spring 版本? [英] Is there a simple way to use a different Spring version?
问题描述
我想在我的 Spring Boot 项目中使用最新的 Spring 4.1.x 快照.
I want to use latest Spring 4.1.x snapshot in my Spring Boot project.
是否有一种简单的方法可以覆盖所有 Spring 依赖项的版本,或者我应该手动包含所有必需的 Spring 依赖项及其所需版本?
Is there a simple way to override the version of all Spring dependencies, or should I include all required Spring dependencies with it's desired version manually?
原因是我想在 REST 服务中试验 Spring 4.1 @JsonView 注释.
Reason is I want experiment with Spring 4.1 @JsonView annotation in REST services.
推荐答案
如果你使用 Maven 和 spring-boot-starter-parent
作为父级,你可以覆盖 spring.version
属性在您的 pom 中更改您正在使用的 Spring 版本:
If you're using Maven with spring-boot-starter-parent
as the parent, you can override the spring.version
property in your pom to change the version of Spring that you're using:
<properties>
<spring.version>4.1.0.BUILD-SNAPSHOT</spring.version>
</properties>
如果您使用的是 Gradle,您可以通过使用解析策略来覆盖具有 org.springframework
组 ID 的所有版本,从而达到相同的效果:
If you're using Gradle, you can achieve the same effect by using a resolution strategy to override the version of everything with the org.springframework
group id:
configurations.all {
resolutionStrategy {
eachDependency {
if (it.requested.group == 'org.springframework') {
it.useVersion '4.1.0.BUILD-SNAPSHOT'
}
}
}
}
这篇关于有没有一种简单的方法来使用不同的 Spring 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!