如何阻止 logback-classic 在运行 mvn 包时重新出现在 m2 存储库中



>我在加载应用程序上下文时遇到以下错误

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:.../repository/org/slf4j/slf4j-nop/1.7.30/slf4j-nop-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:.../repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.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 [org.slf4j.helpers.NOPLoggerFactory]

由于我想保留龙目岛附带的slf4j,因此我尝试删除文件夹logback-classic/1.2.3。但是每当我运行mvn package时它都会回来,所以我的 pom 中一定有一些东西正在重新安装它,但它从未被特别引用,所以必须有一些继承 hullaballoo 发生。

绒球.xml

<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath/>
</parent>
<groupId>**********</groupId>
<artifactId>rest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>rest</name>
<properties>
<java.version>1.8</java.version>
<endpoints.project.id>**********</endpoints.project.id>
</properties>
<dependencies>
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>2.2.1</version>
</dependency>
<!-- [START api_management] -->
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-management-control-appengine-all</artifactId>
<version>1.0.12</version>
</dependency>
<!-- [END api_management] -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.80</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<!-- deploy configuration -->
<projectId>GCLOUD_CONFIG</projectId>
<version>GCLOUD_CONFIG</version>
</configuration>
</plugin>
<!-- [START endpoints_plugin] -->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>endpoints-framework-maven-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<!-- plugin configuration -->
<hostname>${endpoints.project.id}.appspot.com</hostname>
</configuration>
</plugin>
<!-- [END endpoints_plugin] -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

如果有人可以帮助找到有问题的依赖项或帮助我弄清楚如何找到它并摆脱 slf4j 错误,那就太好了。

我在这里回答,因为评论很短:(还不是最终答案(:

它回来了,因为它是spring-boot-starter的传递依赖......或者更准确地说,spring-boot-starter依赖于spring-boot-starter-logging而依赖于logback-classic这是弹簧引导的默认值。

此外,我在龙目岛项目中看不到slf4j

还有一件事,第一个依赖项endpoints-framework包含对SLF4J-NOP的引用,在我看来这是错误的。

除了上面所有配置的版本-maven-plugin并将其绑定到compile阶段是没有意义的,这使得你的构建非常慢。

最新更新