我面临一些如下所示的去重复错误,这表明我的一些依赖项导入了其他的依赖项,这些依赖项包含具有相同路径名的文件。因为它们有相同的路径,所以它们不能一起包含在我试图用sbt程序集创建的jar文件中。
我理解修复它的干净方法是通过修复我的依赖项。下面示例中的冲突依赖项似乎是reactive-streams和reactive-streams-flow-adapters,但我不确定它们是什么以及它们来自何处。如何找到我的哪些依赖项正在导入它们?
如果我能搞清楚,我该怎么解决呢?除了移除其中的一个外,还有别的办法吗?
不重复错误的一个例子:
[error] (assembly) deduplicate: different file contents found in the following:
[error] /home/guillaume/.cache/coursier/v1/https/repo1.maven.org/maven2/org/reactivestreams/reactive-streams-flow-adapters/1.0.2/reactive-streams-flow-adapters-1.0.2.jar:org/reactivestreams/FlowAdapters$FlowPublisherFromReactive.class
[error] /home/guillaume/.cache/coursier/v1/https/repo1.maven.org/maven2/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar:org/reactivestreams/FlowAdapters$FlowPublisherFromReactive.class以下是我的依赖项列表,如果有帮助的话:
libraryDependencies += "com.fasterxml.jackson.core" % "jackson-databind" % "2.12.2",
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",
libraryDependencies += "com.softwaremill.sttp.client3" %% "core" % "3.3.6",
libraryDependencies += "com.softwaremill.sttp.client3" %% "httpclient-backend-zio" % "3.3.6",
libraryDependencies += "dev.zio" %% "zio" % "1.0.9",
// libraryDependencies += "dev.zio" %% "zio-streams" % "1.0.9",
libraryDependencies += "org.apache.commons" % "commons-compress" % "1.20",
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.9",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.9" % "test",
libraryDependencies += ("tech.sparse" %% "toml-scala" % "0.2.2").cross(CrossVersion.for3Use2_13),发布于 2021-06-26 22:06:56
我不熟悉反应性流,但看起来它们在补丁版本期间做了一些更改,并在1.0.3中移动了类。请参阅反应流1.0.3在这里!
当我们发布1.0.2时,我们提供了一个兼容性/转换库来无缝地在
java.util.concurrent.Flow和org.reactivestreams名称空间之间进行转换--在1.0.3中,这些适配器被包含在主1.0.3JAR中。
使用dependencyTree研究传递依赖关系
如何找到我的哪些依赖项正在导入它们?
如果您使用的是最新的SBT1.5.4,默认情况下它有Johannes的依赖关系图插件,因此您可以从shell运行dependencyTree:
sbt:root> dependencyTree
[info] root:root_2.13:0.1.0-SNAPSHOT [S]
....
[info] +-com.softwaremill.sttp.client3:httpclient-backend-zio_2.13:3.3.6 [S]
[info] | +-com.softwaremill.sttp.client3:httpclient-backend_2.13:3.3.6 [S]
[info] | | +-com.softwaremill.sttp.client3:core_2.13:3.3.6 [S]
[info] | | | +-com.softwaremill.sttp.model:core_2.13:1.4.7 [S]
[info] | | | +-com.softwaremill.sttp.shared:core_2.13:1.2.5 [S]
[info] | | | +-com.softwaremill.sttp.shared:ws_2.13:1.2.5 [S]
[info] | | | +-com.softwaremill.sttp.model:core_2.13:1.4.7 [S]
[info] | | | +-com.softwaremill.sttp.shared:core_2.13:1.2.5 [S]
[info] | | |
[info] | | +-org.reactivestreams:reactive-streams-flow-adapters:1.0.2
[info] | | +-org.reactivestreams:reactive-streams:1.0.2 (evicted by: 1.0.3)
[info] | | +-org.reactivestreams:reactive-streams:1.0.3
....这告诉我们org.reactivestreams:reactive-streams-flow-adapters:1.0.2是从com.softwaremill.sttp.client3:httpclient-backend_2.13:3.3.6拉进来的。
不包括无功流.流适配器
如果我能搞清楚,我该怎么解决呢?除了移除其中的一个外,还有别的办法吗?
在本例中,reactive-streams-flow-adapters包含在reactive-streams post1.0.3中,因此我认为可以将其排除在依赖项之外,如下所示:
libraryDependencies += ("com.softwaremill.sttp.client3" %% "httpclient-backend-zio" % "3.3.6")
.exclude("org.reactivestreams", "reactive-streams-flow-adapters"),忽略模块信息类
要忽略module-info.class,我们可以将其添加到build.sbt中
ThisBuild / assemblyMergeStrategy := {
case "module-info.class" => MergeStrategy.discard
case x =>
val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
oldStrategy(x)
}结果
sbt:root> assembly
[info] Strategy 'discard' was applied to 10 files (Run the task at debug level to see details)
[success] Total time: 3 s, completed Jun 26, 2021 6:02:04 PMhttps://stackoverflow.com/questions/68101801
复制相似问题