如何修复“SLF4J:类路径包含多个 SLF4J 绑定"在播放 2.3.x 启动时? [英] How to fix "SLF4J: Class path contains multiple SLF4J bindings" at startup of Play 2.3.x?

查看:37
本文介绍了如何修复“SLF4J:类路径包含多个 SLF4J 绑定"在播放 2.3.x 启动时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我升级了我的 Play 版本和其他库,现在我看到了:

I upgraded my version of Play and other libraries and I now see this:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/paul/.ivy2/cache/org.slf4j/slf4j-nop/jars/slf4j-nop-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/paul/.ivy2/cache/org.slf4j/slf4j-jdk14/jars/slf4j-jdk14-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/paul/.ivy2/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-1.7.7.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]

我试图找出这些来自哪里,但是当我运行 show managed-classpath 时,唯一的 slf4j jars 是

I am trying to track down where these are coming from, but when I run show managed-classpath, the only slf4j jars are

/home/paul/.ivy2/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.7.6.jar
/home/paul/.ivy2/cache/org.slf4j/jul-to-slf4j/jars/jul-to-slf4j-1.7.6.ja
/home/paul/.ivy2/cache/org.slf4j/jcl-over-slf4j/jars/jcl-over-slf4j-1.7.6.jar

我从未见过 slf4j-nop-1.7.7.jarslf4j-jdk14-1.7.7.jarslf4j-simple-1.7.7.jar.

I never see slf4j-nop-1.7.7.jar or slf4j-jdk14-1.7.7.jar or slf4j-simple-1.7.7.jar.

这些在类路径上的情况如何?

How are these on the classpath?

推荐答案

根据评论和可能的解决方案,我可以为没有修复的版本的用户建议我的包含在 build.sbt 中,例如玩2.3.2:

Following the comments and possible solutions I can propose mine for inclusion in build.sbt for users of the versions without the fix, e.g. Play 2.3.2:

libraryDependencies ++= Seq(
  "org.slf4j" % "slf4j-api"       % "1.7.7",
  "org.slf4j" % "jcl-over-slf4j"  % "1.7.7"
).map(_.force())

libraryDependencies ~= { _.map(_.exclude("org.slf4j", "slf4j-jdk14")) }

之前:

--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Ctrl+D to stop and go back to the console...)

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/jacek/.ivy2/cache/org.slf4j/slf4j-nop/jars/slf4j-nop-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jacek/.ivy2/cache/org.slf4j/slf4j-jdk14/jars/slf4j-jdk14-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jacek/.ivy2/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-1.7.7.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]
[info] play - Application started (Dev)

之后(有变化):

--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Ctrl+D to stop and go back to the console...)

[info] play - Application started (Dev)

这些是项目的依赖项:

$ 显示库依赖项[信息] 列表(org.scala-lang:scala-library:2.11.2, com.typesafe.play:twirl-api:1.0.2, com.typesafe.play:play:2.3.2, com.typesafe.play:play-test:2.3.2:test, com.typesafe.play:play-docs:2.3.2:docs, com.typesafe.play:play-jdbc:2.3.2, com.typesafe.play:anorm:2.3.2, com.typesafe.play:play-cache:2.3.2, com.typesafe.play:play-ws:2.3.2, com.typesafe.play:filters-helpers:2.3.2, org.webjars:webjars-play:2.3.0, org.webjars:requirejs:2.1.14-1, org.webjars:underscorejs:1.6.0-3, org.webjars:jquery:2.1.1, org.webjars:bootstrap:3.2.0, org.webjars:angularjs:1.3.0-beta.17, org.postgresql:postgresql:9.3-1102-jdbc41, org.slf4j:slf4j-api:1.7.7, org.slf4j:jcl-over-slf4j:1.7.7)

这篇关于如何修复“SLF4J:类路径包含多个 SLF4J 绑定"在播放 2.3.x 启动时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆