我正在尝试使用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敬请指教。
EDIT2:基于下面的评论。这是新的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"
)有什么想法吗?
发布于 2013-05-23 05:28:48
您的项目没有正确的依赖项。
您已经添加了这个"com.typesafe.akka" %% "akka-actor" % "2.0.5"。这是akka的核心模块的主要依赖项。此外,最好为您的akka项目添加以下内容:
"com.typesafe.akka" %% "akka-actor" % "2.0.5",
"com.typesafe.akka" %% "akka-slf4j" % "2.0.5",
"com.typesafe.akka" %% "akka-remote" % "2.0.5",
"com.typesafe.akka" %% "akka-agent" % "2.0.5",
"com.typesafe.akka" %% "akka-testkit" % "2.0.5"% "test"要使用actors,您应该导入akka.actor._
已更新
好的,这个构建文件适用于我
name := "hello"
version := "1.0"
scalaVersion := "2.10.1"
libraryDependencies ++= Seq(
"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-agent" % "2.2-M3",
"com.typesafe.akka" %% "akka-testkit" % "2.2-M3" % "test"
)别忘了在sbt中reload和update你的项目
发布于 2013-05-24 10:36:09
您的akka-actor依赖关系绝对不能与您的其他依赖关系的版本不同。你添加的任何依赖项都绝对不能依赖于不同版本的akka,否则你会得到一个非常混乱的依赖关系树。
如果你刚开始,你也可以使用当前的版本。Coltrane 2.2-M3在撰写本文时是最新的。
你可以根据需要添加更多的akka库...但这是一个基于我们在prod中运行的实际项目的基本起点:
name := "app"
organization := "com.yourorg"
version := "0.0.1-SNAPSHOT"
scalaVersion := "2.10.1"
scalacOptions ++= Seq("-unchecked", "-deprecation")
resolvers ++= Seq(
"Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
)
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.2-M3",
"com.typesafe.akka" %% "akka-slf4j" % "2.2-M3",
"com.typesafe.akka" %% "akka-testkit" % "2.2-M3"
)发布于 2019-03-24 23:42:24
2019年3月24日更新的
要使用Akka Actor,您需要以下依赖项:
用于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集群、Akka Streams、Akka Http、Alpakka等的更多信息和依赖代码片段,请查看:https://akka.io/docs/
https://stackoverflow.com/questions/16701530
复制相似问题