首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复依赖关系图以解决去重复错误?

如何修复依赖关系图以解决去重复错误?
EN

Stack Overflow用户
提问于 2021-06-23 14:28:26
回答 1查看 234关注 0票数 2

我面临一些如下所示的去重复错误,这表明我的一些依赖项导入了其他的依赖项,这些依赖项包含具有相同路径名的文件。因为它们有相同的路径,所以它们不能一起包含在我试图用sbt程序集创建的jar文件中。

我理解修复它的干净方法是通过修复我的依赖项。下面示例中的冲突依赖项似乎是reactive-streamsreactive-streams-flow-adapters,但我不确定它们是什么以及它们来自何处。如何找到我的哪些依赖项正在导入它们?

如果我能搞清楚,我该怎么解决呢?除了移除其中的一个外,还有别的办法吗?

不重复错误的一个例子:

代码语言:javascript
复制
[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

以下是我的依赖项列表,如果有帮助的话:

代码语言:javascript
复制
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),
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-26 22:06:56

我不熟悉反应性流,但看起来它们在补丁版本期间做了一些更改,并在1.0.3中移动了类。请参阅反应流1.0.3在这里!

当我们发布1.0.2时,我们提供了一个兼容性/转换库来无缝地在java.util.concurrent.Floworg.reactivestreams名称空间之间进行转换--在1.0.3中,这些适配器被包含在主1.0.3JAR中。

使用dependencyTree研究传递依赖关系

如何找到我的哪些依赖项正在导入它们?

如果您使用的是最新的SBT1.5.4,默认情况下它有Johannes的依赖关系图插件,因此您可以从shell运行dependencyTree

代码语言:javascript
复制
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中,因此我认为可以将其排除在依赖项之外,如下所示:

代码语言:javascript
复制
    libraryDependencies += ("com.softwaremill.sttp.client3" %% "httpclient-backend-zio" % "3.3.6")
      .exclude("org.reactivestreams", "reactive-streams-flow-adapters"),

忽略模块信息类

要忽略module-info.class,我们可以将其添加到build.sbt

代码语言:javascript
复制
ThisBuild / assemblyMergeStrategy := {
  case "module-info.class" => MergeStrategy.discard
  case x =>
    val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
    oldStrategy(x)
}

结果

代码语言:javascript
复制
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 PM
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68101801

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档