最近由于要改kafka成datahub,于是在pom文件上引入了
<dependency> <groupId>com.aliyun.datahub</groupId> <artifactId>aliyun-sdk-datahub</artifactId> <version>2.25.1</version> </dependency>
然后让我去测试同事关于datahub的代码,但是我一拉下代码来,项目都跑不起来,就是一顿错呀,
Class path contains multiple SLF4J bindings.
大概意思就是这个slf4j绑定的时候有两个东西要绑定,slf4j就不知道绑定谁了,错误我是知道咋回事,但是不知道咋解决啊喂,周五下午一顿烦躁中解决,加上中秋节后三天上班鼻子塞的像水泥地,白天晚上鼻子不通气,完全没状态搞,终于周末还是内心烦躁,不解决这个问题,我的项目工作就没法往下继续啊,我的测试代码工作还没搞呢啊喂,终于周日上午也就是今天,内心做了好久的斗争,还是打开电脑搞一下吧,碰巧遇到了一篇很不错的文章,解决了这个问题,还真的是因为引入了这个datahub,导致又引入了log4j12,才会使slf4j不知道绑定谁了。
mvn dependency:tree 查看了下
+- com.aliyun.datahub:aliyun-sdk-datahub:jar:2.25.1:compile
[INFO] | +- com.squareup.retrofit2:retrofit:jar:2.9.0:compile
[INFO] | +- com.squareup.retrofit2:converter-jackson:jar:2.9.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.11.4:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.4:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.11.4:compile
[INFO] | +- com.squareup.okhttp3:okhttp:jar:3.14.9:compile
[INFO] | | \- com.squareup.okio:okio:jar:1.17.2:compile
[INFO] | +- com.squareup.okhttp3:logging-interceptor:jar:3.14.9:compile
[INFO] | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] | +- commons-codec:commons-codec:jar:1.14:compile
[INFO] | +- org.lz4:lz4-java:jar:1.4.0:compile
[INFO] | +- com.github.luben:zstd-jni:jar:1.5.5-4:compile
[INFO] | +- commons-io:commons-io:jar:1.3.2:compile
[INFO] | +- io.dropwizard.metrics:metrics-core:jar:4.1.22:compile
[INFO] | +- io.dropwizard.metrics:metrics-json:jar:4.1.22:compile
[INFO] | +- com.google.protobuf:protobuf-java:jar:2.6.1:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.10:compile
[INFO] | +- com.google.guava:guava:jar:30.1.1-jre:compile
[INFO] | | +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] | | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] | | +- org.checkerframework:checker-qual:jar:3.8.0:compile
[INFO] | | +- com.google.errorprone:error_prone_annotations:jar:2.5.1:compile
[INFO] | | \- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] | +- org.slf4j:slf4j-log4j12:jar:1.7.30:compile
[INFO] | | \- log4j:log4j:jar:1.2.17:compile
[INFO] | +- org.apache.arrow:arrow-vector:jar:11.0.0:compile
[INFO] | | +- org.apache.arrow:arrow-format:jar:11.0.0:compile
[INFO] | | +- org.apache.arrow:arrow-memory-core:jar:11.0.0:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.4:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.65.Final:compile
[INFO] | | \- com.google.flatbuffers:flatbuffers-java:jar:1.12.0:compile
[INFO] | +- org.apache.arrow:arrow-memory-netty:jar:11.0.0:compile
[INFO] | | \- io.netty:netty-buffer:jar:4.1.65.Final:compile
[INFO] | +- org.apache.commons:commons-pool2:jar:2.8.1:compile
[INFO] | \- org.apache.avro:avro:jar:1.11.1:compile
[INFO] | \- org.apache.commons:commons-compress:jar:1.21:compile
参考文章:解决SLF4J: Class path contains multiple SLF4J bindings.-CSDN博客