Gradle项目引用zipkin-server时,报错
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/gradle-4.6/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.11.2/4d44e4edc4a7fb39f09b95b09f560a15976fa1ba/log4j-slf4j-impl-2.11.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/wanghui/.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 [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.StackOverflowError
at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:108)
at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:121)
at org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass(StackLocatorUtil.java:55)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:42)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
因为Slf4j2余logback引用的包是冲突的,需要把它排除掉,使用方法
compile (group: 'io.zipkin.java', name: 'zipkin-server', version: '2.12.9'){
exclude group: 'org.slf4j',module: 'slf4j-api'
}
然鹅,还是不正确,报错了,想到可gradle查看包引用的命令,试一试
执行命令
gradle dependencyInsight --dependency 依赖包
例如
gradle dependencyInsight --dependency slf4j-api
貌似也没有问题。。
最后参考官网https://www.slf4j.org/codes.html#multiple_bindings 把第一个文件删除掉了,这样就编译过了
但是这个不是解决问题的办法啊。。。。。