gpt4 book ai didi

scala - 使用 Akka 构建 sbt 需要什么?

转载 作者:行者123 更新时间:2023-12-04 05:52:55 25 4
gpt4 key购买 nike

我正在尝试使用来自 sbt 的 scala -akka。

我的 sbt 文件如下所示:

name := "hello"

version := "1.0"

scalaVersion := "2.9.1"

resolvers += "akka" at "http://repo.akka.io/snapshots"

libraryDependencies ++= Seq(
"com.codahale" % "simplespec_2.9.0-1" % "0.4.1",
"com.typesafe.akka" % "akka-stm" % "2.0-SNAPSHOT"
)

我的代码:
import akka._

object HelloWorld {
def main(args: Array[String]) {
println("Hello, world!")
}
}

当我做 sbt compile ,我得到
]# **sbt compile**
[info] Set current project to default-91c48b (in build file:/var/storage1/home/test_user/dev_scala/hello/)
[info] Compiling 1 Scala source to /var/storage1/home/test_user/dev_scala/hello/target/scala-2.9.2/classes...
[error] /var/storage1/home/test_user/dev_scala/hello/src/main/scala/hw.scala:3: not found: object akka
[error] import akka._
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
[error] Total time: 3 s, completed May 22, 2013 8:59:08 PM

请指教。

编辑2:
根据下面的评论。这是新的 sbt 文件
name := "hello"
version := "1.0"
scalaVersion := "2.9.1"

resolvers += "akka" at "http://repo.akka.io/snapshots"

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.1.4",
"com.codahale" % "simplespec_2.9.0-1" % "0.4.1",
"com.typesafe.akka" % "akka-stm" % "2.0-SNAPSHOT" ,
"com.typesafe.akka" %% "akka-actor" % "2.2-M3",
"com.typesafe.akka" %% "akka-slf4j" % "2.2-M3",
"com.typesafe.akka" %% "akka-remote" % "2.2-M3",
"com.typesafe.akka" %% "akka-testkit" % "2.2-M3"% "test"
)

有任何想法吗 ?

最佳答案

2019 年 3 月 24 日更新

要使用 Akka Actors,您需要以下依赖项:

对于 sbt:

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.5.21",
"com.typesafe.akka" %% "akka-testkit" % "2.5.21" % Test
)

对于 Gradle:
dependencies {
compile group: 'com.typesafe.akka', name: 'akka-actor_2.12', version: '2.5.21'
testCompile group: 'com.typesafe.akka', name: 'akka-testkit_2.12', version: '2.5.21'
}

对于 Maven:
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.12</artifactId>
<version>2.5.21</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_2.12</artifactId>
<version>2.5.21</version>
<scope>test</scope>
</dependency>

有关 Akka Cluster、Akka Streams、Akka Http、Alpakka 等的更多信息和依赖代码片段,请查看: https://akka.io/docs/

关于scala - 使用 Akka 构建 sbt 需要什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16701530/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com