4

我从 akka.io 导入 Await 时出错。这是我的 build.sbt:

name := "Project1"

version := "0.1"

scalaVersion := "2.10.1"

libraryDependencies += "org.json4s" %% "json4s-native" % "3.2.4"

resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"

libraryDependencies += "com.typesafe.akka" % "akka-actor_2.10" % "2.1.4"

这是代码的一部分:

import akka.actor.Actor
import akka.actor.ActorSystem
import akka.actor.Props
import akka.dispatch.Await
import akka.pattern.ask


//.......
private def resultId = {
    private val someActor = context.actorSelection("../someActor123") // defined in   Application object
    val future = someActor ? SomeMessage
    val result = Await.result(future, 1.timeout).asInstanceOf[String]
  }

它说对象Await is not a member of package akka.dispatchvalue ? is not a member of akka.actor.ActorSelectionnot found: value Await

当然,我重新加载它并做了 gen-idea。

4

1 回答 1

8

正如@SRI 指出的那样,您应该使用scala.concurrent.Await而不是akka.dispatch.Await.

价值 ?不是 akka.actor.ActorSelection 的成员

在 version中没有ask模式支持。请参阅此提交。请求支持仅在 version 之后可用。ActorSelection2.1.4ActorSelection2.2

于 2013-07-24T08:57:48.433 回答