概述

项目中经常会导致Jar包冲突问题。

问题描述

项目启动时,有如下报错:
Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/E:/myRepo/org/slf4j/slf4j-simple/1.7.25/slf4j-simple-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/E:/myRepo/org/apache/logging/log4j/log4j-slf4j-impl/2.15.0/log4j-slf4j-impl-2.15.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]

可以看到slf4j-simple-1.7.25.jar 和log4j-slf4j-impl-2.15.0.jar 这两个jar包冲突了。

解决方案

排除slf4j-simple-1.7.25.jar 这个老版本的Jar包。
在idea中可以通过maven-helper插件,查询出slf4j-simple的依赖jar包,然后排除即可。
在这里插入图片描述

        <dependency>
            <groupId>com.test.practice</groupId>
            <artifactId>practice-sdk</artifactId>
            <version>${practice-sdk.version}</version>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-simple</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐