Alpakka 和 Akka 版本兼容性问题
Posted
技术标签:
【中文标题】Alpakka 和 Akka 版本兼容性问题【英文标题】:Alpakka and Akka Version Compatibility Issue 【发布时间】:2021-08-02 09:27:31 【问题描述】:当我尝试 sbt 构建我的项目时,项目构建失败并出现“提取产品结构失败”错误。我怀疑与我用于 Alpakka 和 Akka 的版本有关。
这是我的 build.sbt 文件:
lazy val akkaHttpVersion = "10.2.4" // "10.1.11"
lazy val akkaVersion = "2.6.14" // "2.5.31"
val JacksonVersion = "2.10.5.1"
lazy val root = (project in file(".")).
settings(
inThisBuild(List(
organization := "com.example",
scalaVersion := "2.13.4"//"2.12.11"
)),
name := "XYZ",
libraryDependencies ++= Seq(
"org.orekit" % "orekit" % "10.3",
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-actor-typed" % akkaVersion,
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"ch.qos.logback" % "logback-classic" % "1.2.3",
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % Test,
"com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion % Test,
"org.scalatest" %% "scalatest" % "3.1.4" % Test,
"org.ehcache" % "ehcache" % "3.1.3",
"org.apache.httpcomponents" % "httpclient" % "4.5.13",
"org.scala-lang.modules" %% "scala-parallel-collections" % "0.2.0",
"org.apache.sling" % "sling-maven-plugin" % "2.4.2",
"com.fasterxml.jackson.module" % "jackson-module-scala" % "2.0.2",
"com.fasterxml.jackson.core" % "jackson-databind" % JacksonVersion,
"com.typesafe.akka" %% "akka-stream-kafka" % "2.0.7",
"com.lightbend.akka" %% "akka-stream-alpakka-reference" % "2.0.2"
)
)
当我在库末尾删除 alpakka 依赖项时,错误消失了,但由于缺少 alpakka 依赖项,我无法构建项目。
最终,我只是想实现这个:https://akka.io/alpakka-samples/http-csv-to-kafka/step4.html
Gael: Here is the image of the error message from Intellij
在运行sbt clean compile
时,我得到以下错误堆栈:
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading com.lightbend.akka:akka-stream-alpakka-reference_2.13:2.0.2
[error] Not found
[error] Not found
[error] not found: C:\Users\ihussein\.ivy2\localcom.lightbend.akka\akka-stream-alpakka-reference_2.13\2.0.2\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/com/lightbend/akka/akka-stream-alpakka-reference_2.13/2.0.2/akka-stream-alpakka-reference_2.13-2.0.2.pom
[error] at lmcoursier.CoursierDependencyResolution.unresolvedWarningOrThrow(CoursierDependencyResolution.scala:258)
[error] at lmcoursier.CoursierDependencyResolution.$anonfun$update$38(CoursierDependencyResolution.scala:227)
[error] at scala.util.Either$LeftProjection.map(Either.scala:573)
[error] at lmcoursier.CoursierDependencyResolution.update(CoursierDependencyResolution.scala:227)
[error] at sbt.librarymanagement.DependencyResolution.update(DependencyResolution.scala:60)
[error] at sbt.internal.LibraryManagement$.resolve$1(LibraryManagement.scala:53)
[error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$12(LibraryManagement.scala:103)
[error] at sbt.util.Tracked$.$anonfun$lastOutput$1(Tracked.scala:73)
[error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$20(LibraryManagement.scala:116)
[error] at scala.util.control.Exception$Catch.apply(Exception.scala:228)
[error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11(LibraryManagement.scala:116)
[error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11$adapted(LibraryManagement.scala:97)
[error] at sbt.util.Tracked$.$anonfun$inputChangedW$1(Tracked.scala:219)
[error] at sbt.internal.LibraryManagement$.cachedUpdate(LibraryManagement.scala:130)
[error] at sbt.Classpaths$.$anonfun$updateTask0$5(Defaults.scala:3486)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] at sbt.Execute.work(Execute.scala:291)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] at java.util.concurrent.FutureTask.run(Unknown Source)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
[error] at java.util.concurrent.FutureTask.run(Unknown Source)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[error] at java.lang.Thread.run(Unknown Source)
[error] (update) sbt.librarymanagement.ResolveException: Error downloading com.lightbend.akka:akka-stream-alpakka-reference_2.13:2.0.2
[error] Not found
[error] Not found
[error] not found: C:\Users\ihussein\.ivy2\localcom.lightbend.akka\akka-stream-alpakka-reference_2.13\2.0.2\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/com/lightbend/akka/akka-stream-alpakka-reference_2.13/2.0.2/akka-stream-alpakka-reference_2.13-2.0.2.pom
【问题讨论】:
您的build.sbt
对我来说非常好用。您还有其他错误消息吗?
@GaëlJ 我在 Intellij 中添加了一个指向错误消息图像的链接。如果我删除对 alpakka 的依赖,这个错误就会消失,但是因为库不再存在,代码中对其对象的引用会导致构建错误。谢谢!
在 IntelliJ Idea 中,您可以单击屏幕截图中显示的不同行,右侧应显示更多详细信息。您也可以暂时摆脱 IntelliJ 并在 shell 中运行 sbt clean compile
以检查它是否更好。
再次感谢@GaëlJ。 Intellij 错误报告中未显示任何内容。我在我的帖子中添加了来自sbt clean compile
命令的响应。
akka-stream-alpakka-reference
似乎不存在,所以我很好奇它为什么存在(它不在项目的 github 版本中)
【参考方案1】:
看来我需要使用"com.lightbend.akka" %% "akka-stream-alpakka-csv" % "2.0.2"
而不是 "com.lightbend.akka" %% "akka-stream-alpakka-reference" % "2.0.2"
。
【讨论】:
以上是关于Alpakka 和 Akka 版本兼容性问题的主要内容,如果未能解决你的问题,请参考以下文章