运行代码,slf4j出现如下问题:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/cyxinda/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/cyxinda/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.13.3/log4j-slf4j-impl-2.13.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]
11:17:37.304 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
是说slf4j的实现jar冲突了 解决方式是: 运行
cyxinda@oldsix:/workspace/java/demo/demo-with-jmx-mysql$ mvn dependency:tree > /tmp/dependecy.log
cyxinda@oldsix:/workspace/java/demo/demo-with-jmx-mysql$ vim /tmp/dependecy.log
发现milvus-sdk-jar依赖的是org.apache.logging.log4j:log4j-slf4j-impl
我们在项目中,使用的是logback,所以,排除该依赖即可。
<dependency>
<groupId>io.milvus</groupId>
<artifactId>milvus-sdk-java</artifactId>
<version>2.3.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
再次运行代码,已经没有出现相应的问题了。