使用dropwizard的阴影罐子,我得到:类路径包含多个SLF4J绑定 [英] With the shaded jar from dropwizard I got: Class path contains multiple SLF4J bindings

查看:68
本文介绍了使用dropwizard的阴影罐子,我得到:类路径包含多个SLF4J绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可能在这里做了一些愚蠢的事情. 我的dropwizard设置出现了一些(小问题).运行带阴影的jar可以正常工作,但是在执行集成测试时,我会收到以下警告:

I probably made something stupid here. There is something (smallish) wrong with my dropwizard setup. Running the shaded jar works fine, but when executing integration tests I get this warning:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/graphhopper/web/target/graphhopper-web-0.11-SNAPSHOT.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/user/.m2/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 [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
INFO  [2018-04-08 18:44:27,653] org.eclipse.jetty.util.log: Logging initialized @1090ms to org.eclipse.jetty.util.log.Slf4jLog

其中graphhopper-web-0.11-SNAPSHOT.jar是带有dropwizard的阴影jar(带有logback).

Where graphhopper-web-0.11-SNAPSHOT.jar is the shaded jar with dropwizard (with logback).

通常意味着类路径上有多个slf4j绑定,但我可以拒绝这一理论,只有slf4j- api在那里,还有dropwizard的logback依赖关系.我还使用Netbeans和

This usually means that more than one slf4j binding is on the classpath but I could reject this theory and only slf4j-api is there, plus the logback dependency for dropwizard. I also have analyzed the dependency graph with Netbeans and

mvn dependency:tree -Dverbose -Dincludes=org.slf4j

(请参见输出此处)) 但找不到任何问题.

(see output here) but couldn't find something problematic.

是否可以将mvn clean install的阴影jar(带有logback)与其他jar(包括logb​​ack)一起放入类路径中?我如何避免这种情况?

Can it be that the shaded jar (with logback) is somehow put into the classpath with the other jars (including logback) for mvn clean install? How could I avoid this?

通过以下方式复制它:

git clone https://github.com/graphhopper/graphhopper
cd web
mvn clean install

请参见此问题.

推荐答案

将您的代码导入了我的intellij社区版本,并对Web模块pom.xml中的所有依赖项添加了以下排除.它解决了给定问题的问题.您可能在各个模块中进行了更改.

imported your code into my intellij community edition, added exclusion as follows to all the dependency in pom.xml of web module. It resolve issues given issue. You may have do changes in respective module.

示例:

<dependency>
  <groupId>io.dropwizard</groupId>
  <artifactId>dropwizard-core</artifactId>
  <version>1.2.2</version>
  <exclusions>
    <exclusion>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </exclusion>
  </exclusions>
</dependency>

这篇关于使用dropwizard的阴影罐子,我得到:类路径包含多个SLF4J绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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