SLF4J导致多个类名与sbt程序集冲突

SLF4J导致多个类名与sbt程序集冲突,sbt,sbt-assembly,Sbt,Sbt Assembly,我得到了著名的SLF4J类名与sbt程序集的冲突错误(如下)。研究表明,SLF4J在这方面是病理性的,在某种程度上有点模糊。无论如何,这种情况发生在一个有很多依赖项的项目中,现在还不清楚应该如何判断哪些类可以被丢弃以避免冲突而不会在运行时崩溃 [error] (project-name/*:assembly) deduplicate: different file contents found in the following: [error] .ivy2/cache/commons-loggi

我得到了著名的SLF4J类名与sbt程序集的冲突错误(如下)。研究表明,SLF4J在这方面是病理性的,在某种程度上有点模糊。无论如何,这种情况发生在一个有很多依赖项的项目中,现在还不清楚应该如何判断哪些类可以被丢弃以避免冲突而不会在运行时崩溃

[error] (project-name/*:assembly) deduplicate: different file contents found in the following:
[error] .ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.2.jar:org/apache/commons/logging/Log.class
[error] .ivy2/cache/org.slf4j/jcl-over-slf4j/jars/jcl-over-slf4j-1.7.12.jar:org/apache/commons/logging/Log.class
[error] deduplicate: different file contents found in the following:
[error] .ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.2.jar:org/apache/commons/logging/LogConfigurationException.class
[error] .ivy2/cache/org.slf4j/jcl-over-slf4j/jars/jcl-over-slf4j-1.7.12.jar:org/apache/commons/logging/LogConfigurationException.class
[error] deduplicate: different file contents found in the following:
[error] .ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.2.jar:org/apache/commons/logging/LogFactory.class
[error] .ivy2/cache/org.slf4j/jcl-over-slf4j/jars/jcl-over-slf4j-1.7.12.jar:org/apache/commons/logging/LogFactory.class
[error] deduplicate: different file contents found in the following:
[error] .ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.2.jar:org/apache/commons/logging/impl/NoOpLog.class
[error] .ivy2/cache/org.slf4j/jcl-over-slf4j/jars/jcl-over-slf4j-1.7.12.jar:org/apache/commons/logging/impl/NoOpLog.class
[error] deduplicate: different file contents found in the following:
[error] .ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.2.jar:org/apache/commons/logging/impl/SimpleLog$1.class
[error] .ivy2/cache/org.slf4j/jcl-over-slf4j/jars/jcl-over-slf4j-1.7.12.jar:org/apache/commons/logging/impl/SimpleLog$1.class
[error] deduplicate: different file contents found in the following:
[error] .ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.2.jar:org/apache/commons/logging/impl/SimpleLog.class
[error] .ivy2/cache/org.slf4j/jcl-over-slf4j/jars/jcl-over-slf4j-1.7.12.jar:org/apache/commons/logging/impl/SimpleLog.class
[error] deduplicate: different file contents found in the following:
[error] .ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.3.jar:org/slf4j/impl/StaticLoggerBinder.class
[error] .ivy2/cache/org.slf4j/slf4j-nop/jars/slf4j-nop-1.6.4.jar:org/slf4j/impl/StaticLoggerBinder.class
[error] deduplicate: different file contents found in the following:
[error] .ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.3.jar:org/slf4j/impl/StaticMDCBinder.class
[error] .ivy2/cache/org.slf4j/slf4j-nop/jars/slf4j-nop-1.6.4.jar:org/slf4j/impl/StaticMDCBinder.class
[error] deduplicate: different file contents found in the following:
[error] .ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.3.jar:org/slf4j/impl/StaticMarkerBinder.class
[error] .ivy2/cache/org.slf4j/slf4j-nop/jars/slf4j-nop-1.6.4.jar:org/slf4j/impl/StaticMarkerBinder.class
解决这一糟糕局面的方法是什么?我真的很想知道,事实上,为什么这是打包中的问题(
sbt assembly
),而不是像在
sbt run
中那样在sbt中运行项目


非常感谢

您是否阅读了README.md中指向的实际链接

从Jakarta Commons Logging(JCL)逐步迁移到SLF4J jcl-over-slf4j.jar 为了便于从JCL迁移到SLF4J,SLF4J发行版包括jar文件JCL-over-SLF4J.jar。此jar文件旨在作为JCL版本1.1.1的替代品。它实现了JCL的公共API,但在下面使用了SLF4J,因此命名为“JCL over SLF4J”

我们的JCL over SLF4J实现将允许您逐步迁移到SLF4J,特别是如果您的软件所依赖的某些库在可预见的将来继续使用JCL

jcl-over-slf4j.jar
“旨在作为jcl 1.1.1版的替代品。”因此,它的目的是正确地删除公共日志记录

解决这一糟糕局面的方法是什么

运行
showupdate
,找出commons日志记录的来源,并将其从依赖项中排除

我真的很想知道,事实上,为什么这是打包中的问题(
sbt assembly
),而不是像在
sbt run
中那样在sbt中运行项目


这是一个实际的病理类路径。在日志记录方面,您的代码的某些部分可能会做一些完全出乎意料的事情。如果你想选择俄罗斯轮盘赌路线,总有一个合并策略。首先,我在发布了以下内容后,已经绕过了俄罗斯轮盘赌路线:-),这就是为什么我认为我应该在这里更好地了解问题的根源。不,我没有读过那个链接,非常感谢。所以我运行了
show update
,有一堆
commons日志记录的条目,每个条目都有不同的呼叫者列表。。。我应该从我的DEP中排除什么?如何排除?如果我只是排除了
commons日志记录
为什么要查找它的来源?