【问题标题】:Eclipse running SpringBoot: SLF4J: Class path contains multiple SLF4J bindingsEclipse 运行 SpringBoot:SLF4J:类路径包含多个 SLF4J 绑定
【发布时间】:2020-10-19 21:29:34
【问题描述】:

每当我启动基于 SpringBoot 的应用程序(以 Maven 构建/目标 spring-boot:run 运行)时,我都会收到臭名昭著的 SLF4J 警告:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/U:/eclipse/eclipse-jee/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/U:/eclipse/eclipse-jee/configuration/org.eclipse.osgi/8/0/.cp/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.impl.SimpleLoggerFactory]

这个警告让我非常恼火,因为当从 Eclipse 演示应用程序时,潜在客户或用户看到的第一件事就是一个大红色的多余警告。我讨厌那个!看起来很不专业!

现在 - 原则上警告是明确的:有两个 SLF4J 绑定,一个应该摆脱其中一个。我找到了杂项。对相同错误的描述,其中一些还解释了如何定位(通常是传递的)依赖项,然后从 pom 中的依赖项中排除其中一个。

我试过了,但这些建议都不适合我!也提出了解决方案 Eclipse Maven: SLF4J: Class path contains multiple SLF4J bindings(即使用外部 Maven 安装)不起作用!

仔细查看我声称的警告中列出的路径,Eclipse 本身已经有两个绑定(在插件 org.eclipse.osgi... 和 org.eclipse.m2e.maven.runtime.slf4j .simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar),这可能解释了为什么我的尝试没有结果:修改应用程序的 pom 并没有改变与这些 Eclipse 内部绑定有关的任何内容。上面提到的 append 得出了相同的结论:这是 eclipse 中的一个 bug。

但是有没有人知道消除该警告需要什么?我对各种“黑客”持开放态度!可以一个例如“按摩” ...m2e.maven.runtime. 的 jar 不再包含 org/slf4j/impl/StaticLoggerBinder.class(或者可能更确切地说是它包含的 jar)?还是有更好/更安全的方法? 在 Eclipse 中消除该警告需要什么?

【问题讨论】:

    标签: eclipse spring-boot maven


    【解决方案1】:

    对我来说Eclipse Maven: SLF4J: Class path contains multiple SLF4J bindings 工作。在 Debian Linux 中,我将 /usr/share/maven 添加到 Window/Preferences/Maven/Installations 并且这些警告消失了。

    【讨论】:

    • 正如我所写:我也尝试过。我的路径(在 Windows 10 上)指向“C:\Program Files\Apache\Maven”,但这些“SLF4J:类路径包含多个 SLF4J 绑定......”警告(如我最初的问题所示)仍然出现。 :-(
    猜你喜欢
    • 2016-03-12
    • 1970-01-01
    • 2012-12-11
    • 2021-05-23
    • 2014-05-18
    • 2012-09-11
    • 2021-05-19
    • 2020-07-07
    相关资源
    最近更新 更多