如何覆盖Spring Boot依赖项的默认版本?

时间:2016-09-21 10:06:59

标签: spring maven spring-boot pom.xml

如何更改Spring Boot依赖项的默认版本? 例如,Spring Boot 1.4使用Thymeleaf 2.1版本,但最新版本的Thymeleaf是3.0。那么如何将2.1版更改为3.0?

2 个答案:

答案 0 :(得分:10)

文档describes how to do this

根据问题上的标签判断,您正在使用Maven。您应该在应用程序的pom.xml中添加一个属性来设置Thymeleaf版本:

<properties>
    <thymeleaf.version>3.0.1.RELEASE</thymeleaf.version>
</properties>

还有一个sample application,它展示了如何将Thymeleaf 3.0与Spring Boot 1.4结合使用。

答案 1 :(得分:8)

Andy提供的答案仅在您的POM继承自spring-boot-dependencies时才有效。通过spring-boot-dependencies添加dependencyManagement时,您必须重新定义要覆盖的所有工件。无赖!

这也在Andy引用的文档中说明(可能稍后会添加)。