如何从弹簧靴pom中排除或替换杰克逊

问题描述 投票:1回答:2

我正在使用春季靴子1.5.12.RELEASE。它工作正常,我能够建立项目。

但现在我想将spring boot版本升级到1.5.15.RELEASE。而我正在低于错误。

插件org.springframework.boot:spring-boot-maven-plugin:1.5.15.RELEASE或其中一个依赖项无法解析:无法读取org.springframework.boot的工件描述符:spring-boot-maven-plugin: jar:1.5.15.RELEASE:无法转移com.fasterxml.jackson:jackson-bom:pom:2.8.11.20180608

我有我的存储库所以我无法从maven repo下载文件。我有杰克逊2.8.11.20180217的版本。我没有版本2.8.11.20180608。

那么有没有办法使用版本2.8.11.20180217而不是2.8.11.20180608或不使用杰克逊。

java spring maven spring-boot pom.xml
2个回答
3
投票

为所需的jackson版本添加maven依赖项,并为所有需要id的模块排除jackson依赖项:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

2
投票

很可能你是从一些依赖继承jar。首先,搜索需要排除的依赖项所在的位置:

mvn dependency:tree -Dverbose

-Dverbose选项将显示所有依赖项,甚至删除的依赖项。

阅读here了解更多信息

然后,当您找到它时,选择其中包含该依赖项的依赖项,并将其排除

    <dependency>
        <groupId>groupId</groupId>
        <artifactId>artifactId</artifactId>
        <version>xxx</version>
        <exclusions> <!-- This is what you need to add -->
            <exclusion>
                <groupId>theGroupIdToExclude</groupId>
                <artifactId>theArtifactIdToExclude</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
© www.soinside.com 2019 - 2024. All rights reserved.