简体   繁体   English

如何从Spring Boot Pom中排除或更换Jackson

[英]how to exclude or replace the jackson from spring boot pom

I'm using spring boot 1.5.12.RELEASE. 我正在使用Spring Boot 1.5.12.RELEASE。 It is working fine and I'm able to build the project. 一切正常,我能够构建该项目。

But now I want to upgrade the spring boot version to 1.5.15.RELEASE. 但是现在我想将Spring Boot版本升级到1.5.15.RELEASE。 and I'm getting below error. 而且我正在错误以下。

Plugin org.springframework.boot:spring-boot-maven-plugin:1.5.15.RELEASE or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.springframework.boot:spring-boot-maven-plugin:jar:1.5.15.RELEASE: Failure to transfer com.fasterxml.jackson:jackson-bom:pom:2.8.11.20180608 插件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

I have my repository so I can't download the file from maven repo. 我有我的存储库,所以无法从Maven存储库下载文件。 I'm having the version for jackson 2.8.11.20180217. 我有杰克逊2.8.11.20180217的版本。 I don't have the version 2.8.11.20180608. 我没有2.8.11.20180608版本。

So is there any way to use the version 2.8.11.20180217 instead of 2.8.11.20180608 or not use jackson. 所以有什么办法可以使用2.8.11.20180217版本而不是2.8.11.20180608或不使用jackson。

Add the maven dependency for the jackson version you want and exclude jackson dependency for all the modules that need id : 为所需的杰克逊版本添加maven依赖关系,并为所有需要id的模块排除杰克逊依赖关系:

    <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>

Most probably you are inheriting the jar from some of your dependencies. 您很可能是从某些依赖项继承了jar。 First, search where is the dependency that you need to exclude with: 首先,搜索需要排除的依赖关系在哪里:

mvn dependency:tree -Dverbose

The -Dverbose option will show all dependencies, even the ones removed. -Dverbose选项将显示所有依赖项,甚至包括已删除的依赖项。

Read here for more info 在这里阅读更多信息

Then, when you find it, select the dependency that has that inside of it, and exclude with 然后,找到它时,选择其中包含该依赖的依赖项,并用

    <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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM