【发布时间】:2017-01-29 12:34:08
【问题描述】:
如何更改 Spring Boot 依赖项的默认版本? 例如 Spring Boot 1.4 使用 Thymeleaf 2.1 版本,但 Thymeleaf 的最新版本是 3.0。那么如何将2.1版本改为3.0呢?
【问题讨论】:
标签: spring maven spring-boot pom.xml
如何更改 Spring Boot 依赖项的默认版本? 例如 Spring Boot 1.4 使用 Thymeleaf 2.1 版本,但 Thymeleaf 的最新版本是 3.0。那么如何将2.1版本改为3.0呢?
【问题讨论】:
标签: spring maven spring-boot pom.xml
从问题上的标签来看,您使用的是 Maven。您应该在应用程序的 pom.xml 中添加一个属性来设置 Thymeleaf 版本:
<properties>
<thymeleaf.version>3.0.1.RELEASE</thymeleaf.version>
</properties>
还有一个sample application 展示了如何将 Thymeleaf 3.0 与可能感兴趣的 Spring Boot 1.4 结合使用。
【讨论】:
Andy 提供的答案仅在您的 POM 继承自 spring-boot-dependencies 时才有效。当通过dependencyManagement 添加spring-boot-dependencies 时,您必须重新定义要覆盖的所有工件。无赖!
这在Andy引用的文档中也有说明(可能是后来添加的)。