SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation
from SLF4J multiple_bindings Doc
NOTE The warning emitted by SLF4J is just that, a warning. Even when multiple bindings are present, SLF4J will pick one logging framework/implementation and bind with it. The way SLF4J picks a binding is determined by the JVM and for all practical purposes should be considered random.
如上所示, 由于 SLF4J binding 是 random 的,所以这里就随机引用到了 Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory] 导致 IllegalArgumentException
把此 gradle 项目换成 maven 时,它就随机绑定到了 Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] , 此时启动没问题, 但是对于 gradle 项目还是想去解决这个问题。
主要问题还是引的 jar 依赖( soot-infoflow-cmd )里直接把 slf4j 侵入到代码里了,所以无法在这个依赖下 exclude 掉内部的 slf4j。
解决方式也说了, Either remove Logback or the competing implementation , 要删 logback,可是我不想 exclude springboot-starter-logging, 要么 competing implementation,
那么这里如何去 compete implementation 呢?如何让它强制 bind [ch.qos.logback.classic.util.ContextSelectorStaticBinder] 呢?