当前位置: 首页 > 知识库问答 >
问题:

SLF4J:类路径包含多个SLF4J绑定spring Maven

宰父保臣
2023-03-14

在将apache.mahout添加到pom.xml之后,我在运行spring项目时开始出现这个警告,我想知道如何抑制这个警告。

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/Kapio/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/Kapio/.m2/repository/org/slf4j/slf4j-log4j12/1.7.30/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

这是我的pom.xml

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.5.RELEASE</version>
        <relativePath/> 
    </parent>

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

    <dependencies>

            <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>

        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>

        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.mahout</groupId>
            <artifactId>mahout-mr</artifactId>
            <version>0.10.0</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

我试图排除slf4j-log4j12,但仍然不能工作,每次都有警告

<exclusions>
   <exclusion>
      <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>        
   </exclusion>
</exclusions>

我找遍了所有的地方,但我无法移除警告。

有什么建议吗?

共有1个答案

岳迪
2023-03-14
  1. 您需要找出谁拉入slf4j-log4j。在pom.xml目录中的命令行上执行“mvn:dependency:tree”,并找到将其拉入的依赖项。
  2. 对该依赖项进行排除。全局排除不起作用。
  3. 应该可以。
 类似资料: