slf4j版本不兼容

slf4j version incompatibility

我正在尝试在我的项目中使用 org.reflections 库。我将它添加到我的 gradle 依赖项列表中,但是当我 运行 我的代码时,我得到以下信息:

SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding.
SLF4J: Your binding is version 1.5.5 or earlier.
SLF4J: Upgrade your binding to version 1.6.x.

java.lang.NoSuchMethodError:  org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder;

我知道这是因为我的一个依赖项在内部使用了与 org.reflections 正在使用的版本不兼容的更高版本的 slf4j。

我看到了确保最后包含旧版本的 jar 的建议。我怎样才能在 Gradle 中做到这一点,或者是否有其他解决方案 H

这样试试:

compile (group: 'org.reflections', name: 'reflections', version: '0.9.10'){
    exclude group : "org.slf4j"
}

从您的 org.reflections 依赖项中排除 slf4j