如何在 Spring Boot 中覆盖托管版本的依赖项 [英] How to override the managed version of dependencies in Spring Boot

查看:103
本文介绍了如何在 Spring Boot 中覆盖托管版本的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring Boot 允许我们使用以下方法更改 Java 版本:

Spring Boot allows us to change the Java version using:

<properties>
    <java.version>1.8</java.version>
</properties>

在我的 Spring Boot pom.xml 中是否有任何属性可以更改 Java EE 版本或 spring 版本?

Is there any property to change the Java EE version or spring version in my Spring Boot pom.xml?

目前我使用以下方法覆盖托管版本:

Currently I override the managed version using:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
</dependency>

有没有更好的方法来做到这一点,比如只设置属性?

Is there a better way to do this, like just setting properties?

Spring Boot 1.2.3 默认为您提供 Spring 4.1.6.如何仅通过设置属性来强制 Spring Boot 为我提供 4.1.5?

Spring Boot 1.2.3 gives you Spring 4.1.6 by default. How can I force Spring Boot to give me 4.1.5 instead, just by setting properties?

推荐答案

在你的 pom.xml 中应该这样做:

This in your pom.xml should do it:

<properties>
    <spring.version>4.1.5.RELEASE</spring.version>
</properties>

直接来自 文档.

在过度覆盖依赖版本之前,请注意以下建议(来自上面的链接):

Before you go overboard overriding versions of dependencies, heed this advise (from the link above):

每个 Spring Boot 版本都针对一组特定的第三方依赖项进行设计和测试.覆盖版本可能会导致兼容性问题.

Each Spring Boot release is designed and tested against a specific set of third-party dependencies. Overriding versions may cause compatibility issues.

这篇关于如何在 Spring Boot 中覆盖托管版本的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆