我尝试使用Scala 2.12.3,sbt 0.13.6以及build.sbt文件中的以下库依赖项构建项目:
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.5.4",
"com.typesafe.akka" %% "akka-stream" % "2.5.4",
"com.typesafe.akka" %% "akka-stream-testkit" % "2.5.4" % Test,
"com.typesafe.akka" %% "akka-http" % "10.0.9",
"com.typesafe.akka" %% "akka-http-core" % "10.0.9",
"org.scalatest" %% "scalatest" % "3.0.1" % Test)
但是,我一直收到有关版本冲突的以下警告......似乎akka-http
对Akka / Streams版本2.4.19具有传递依赖性。我找到了一个类似的post,建议明确添加akka-streams作为依赖,并确保它与akka-actor的版本相同。以下是依赖警告:
[warn] Found version conflict(s) in library dependencies; some are
suspected to be binary incompatible:
[warn]
[warn] * com.typesafe.akka:akka-stream_2.12:2.5.4 is selected over
2.4.19
[warn] +- com.typesafe.akka:akka-http-core_2.12:10.0.9
(depends on 2.4.19)
[warn] +- com.werner.opttech:dependency-test_2.12:0.0.0
(depends on 2.4.19)
[warn]
[warn] * com.typesafe.akka:akka-actor_2.12:2.5.4 is selected over
2.4.19
[warn] +- com.werner.opttech:dependency-test_2.12:0.0.0
(depends on 2.5.4)
[warn] +- com.typesafe.akka:akka-stream_2.12:2.5.4
(depends on 2.5.4)
[warn] +- com.typesafe.akka:akka-parsing_2.12:10.0.9
(depends on 2.4.19)
有关如何解决此错误的任何建议,以便我可以使用最新版本的akka,akka streams和akka http?谢谢!
答案 0 :(得分:2)
您的配置正确,因为它遵循您提到的compatibility guidelines。我认为你将警告信息误解为错误;你 使用这些库的2.5.4版本。仔细看看这个片段:
[warn] * com.typesafe.akka:akka-actor_2.12:2.5.4 is selected over 2.4.19
sbt确实在挑选akka-actor
库的2.5.4版而不是版本2.4.19。
此外,在sbt控制台中运行show update
会输出以下内容:
[info] com.typesafe.akka:akka-actor_2.12
[info] - 2.5.4
[info] status: release
[info] publicationDate: Thu Aug 10 09:17:00 EDT 2017
....
[info] - 2.4.19
[info] evicted: true
[info] evictedData: latest-revision
sbt驱逐akka-actor
的版本2.4.19,转而支持版本2.5.4。
警告消息实际上确认您正在使用当前版本的Akka工具。
答案 1 :(得分:1)
chunjef的回答是正确的。如果您确实要清除警告,请将以下代码添加到build.sbt。
conflictManager := ConflictManager.strict
dependencyOverrides += "com.typesafe.akka" %% "akka-actor" % "2.5.4"
dependencyOverrides += "com.typesafe.akka" %% "akka-stream" % "2.5.4"
dependencyOverrides += "org.scala-lang" % "scala-library" % "2.12.3"
答案 2 :(得分:1)
有点相关: akka-http 10.1.0-RC1 removes the transient dependency:
我们更改了策略,不再明确依赖
akka-stream
,而是在构建中将其标记为provided
依赖项。这意味着您必须始终向akka-stream
添加手动依赖项。