首页 > 解决方案 > 春季启动时的“为 gson 覆盖托管版本 2.8.1”警告会有多糟糕?怎么可能避免?

问题描述

我在我的父项目中使用 spring-boot。在一个子项目中,我打算使用 Gson 库。当我将它添加到子项目时

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.1</version>
</dependency>

我收到了这个警告:

Overriding managed version 2.8.1 for gson

删除后<version>,我收到此警告:

The managed version is 2.8.1 The artifact is managed in org.springframework.boot:spring-boot-dependencies:1.5.7.RELEASE

pom既然它已经存在于 spring-boot 中,为什么在我从无法导入Gson到我的类中删除依赖项之后呢?我应该如何将这个库与 spring-boot 一起使用?

编辑

我尝试过了

<exclusions>
    <exclusion>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
    </exclusion>
</exclusions>

在我的spring-boot-starter-web, spring-boot-starter-tomcat, spring-boot-starter-logging, spring-boot-starter-data-jpaand spring-boot-starter-cache(我所有的 spring-boot 依赖项),但它没有工作。

使用原始dependency标签,我成功地在 Java 中使用了这个依赖项,但我的问题是忽略这个警告有多糟糕?使用不同的 Gson 版本依赖项会出现什么问题?

标签: javaspringspring-bootgson

解决方案


推荐阅读