如何在Scala 3中使用akka?

mitkmikd  于 2022-11-05  发布在  Scala
关注(0)|答案(2)|浏览(193)

如何在Scala 3中使用akka?我在使用Scala 3时找不到akka依赖项
sbt错误:

[error]   not found: /Users/admin/.ivy2/localcom.typesafe.akka/akka-actor-typed_3/2.6.15/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/com/typesafe/akka/akka-actor-typed_3/2.6.15/akka-actor-typed_3-2.6.15.pom
[error] (ssExtractDependencies) sbt.librarymanagement.ResolveException: Error downloading com.typesafe.akka:akka-actor-typed_3:2.6.15
[error]   Not found
[error]   Not found
[error]   not found: /Users/admin/.ivy2/localcom.typesafe.akka/akka-actor-typed_3/2.6.15/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/com/typesafe/akka/akka-actor-typed_3/2.6.15/akka-actor-typed_3-2.6.15.pom
0ve6wy6x

0ve6wy6x1#

akka-actor-typed是针对Scala 2.12、2.13发布的,而不是针对Scala 3发布的
https://mvnrepository.com/artifact/com.typesafe.akka/akka-actor-typed
尝试兼容模式

lazy val foo = project.in(file("foo"))
  .settings(
    scalaVersion := "3.0.0",
    libraryDependencies += 
      ("com.typesafe.akka" %% "akka-actor-typed" % "2.6.15")
        .cross(CrossVersion.for3Use2_13)
  )

https://docs.scala-lang.org/scala3/guides/migration/compatibility-classpath.html

更新。akka-actor-typed自Scala 3 2.6.17版本起发布

libraryDependencies += "com.typesafe.akka" %% "akka-actor-typed" % "2.6.17"
x7rlezfr

x7rlezfr2#

为了在Scala 3中使用akka,例如akka-actor-typed,您可以将akka-actor-typed 2.6.18作为依赖项包含在内。
提供的示例使用akka-actor-typed 2.6.15,其目标是scala 2.13和2.12。
Scala 3仅在akka-actor-typed 2.6.17之后作为目标包含。
akka-actor-typed的最新版本是akka-actor-typed 2.6.18,其中scala 3作为一个目标。

相关问题