我有使用新Akka 2.4.0的代码。显然我有一些用早期版本编译的库,所以我得到了警告/错误。
最有问题的是,我得到了一个模糊的参考问题,如下所示。
好的,所以编译器警告我(我认为)它使旧的Akka版本更有利于2.4.0,然后它对akka.pattern.ask感到困惑。
我该怎么办呢?
我的输出如下:
> test:compile
[info] Compiling 5 Scala sources to /Users/wmy965/git/hello/common/target/scala-2.11/test-classes...
[error] /Users/wmy965/git/hello/common/src/test/scala/common.test.service/FacilitiesTests.scala:16: ambiguous reference to overloaded definition,
[error] both method ask in trait AskSupport of type (actorSelection: akka.actor.ActorSelection, message: Any, sender: akka.actor.ActorRef)(implicit timeout: akka.util.Timeout)scala.concurrent.Future[Any]
[error] and method ask in trait AskSupport of type (actorSelection: akka.actor.ActorSelection, message: Any)(implicit timeout: akka.util.Timeout)scala.concurrent.Future[Any]
[error] match expected type ?
[error] import akka.pattern.ask._
[error] ^
[error] /Users/wmy965/git/hello/common/src/test/scala/common.test.service/FacilitiesTests.scala:43: value ? is not a member of akka.actor.ActorRef
[error] Error occurred in an application involving default arguments.
[error] val result = Misc.await(harness.facilities.mongoControl ? MongoAction({ mongo =>
[error] ^
[error] two errors found
[error] (common/test:compileIncremental) Compilation failed
[error] Total time: 1 s, completed Oct 23, 2015 5:57:17 PM
> evicted
[info] Updating {file:/Users/wmy965/git/hello/}hello...
[info] Updating {file:/Users/wmy965/git/hello/}common...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Resolving org.scala-lang.modules#scala-xml_2.11;1.0.4 ...
[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn] * com.typesafe.akka:akka-actor_2.11:(2.3.12, 2.3.7) -> 2.4.0 (caller: com.cof:common_2.11:reactive2_a6d8f9, com.typesafe.akka:akka-stream-experimental_2.11:1.0, co.blocke:laterabbit_2.11:0.3, com.typesafe.akka:akka-slf4j_2.11:2.4.0, com.thenewmotion.akka:akka-rabbitmq_2.11:1.2.4)
[info] Here are other libraries that were evicted:
[info] * org.slf4j:slf4j-api:(1.7.7, 1.6.0) -> 1.7.12 (caller: com.bionicspirit:shade_2.11:1.7.Z, org.mongodb:casbah-core_2.11:2.8.2, org.mongodb:casbah-gridfs_2.11:2.8.2, org.slf4j:slf4j-simple:1.7.7, com.typesafe.akka:akka-slf4j_2.11:2.4.0, org.mongodb:casbah-commons_2.11:2.8.2, org.mongodb:casbah-query_2.11:2.8.2)
[info] * org.mongodb:casbah_2.11:2.8.0 -> 2.8.2 (caller: com.cof:common_2.11:reactive2_a6d8f9, co.blocke:scalajack_mongo_2.11:4.4.1)
[info] * org.scala-lang:scala-reflect:2.11.0 -> 2.11.7 (caller: co.blocke:scalajack_2.11:4.4.1, org.monifu:monifu-core_2.11:0.7.0)
[info] * org.joda:joda-convert:1.2 -> 1.7 (caller: com.github.nscala-time:nscala-time_2.11:1.0.0, co.blocke:scalajack_2.11:4.4.1)
[info] * org.scala-lang:scala-library:(2.11.0, 2.11.5, 2.11.4) -> 2.11.7 (caller: com.bionicspirit:shade_2.11:1.7.Z, com.github.nscala-time:nscala-time_2.11:1.0.0, com.typesafe.akka:akka-http-experimental_2.11:1.0, com.typesafe.akka:akka-stream-experimental_2.11:1.0, co.blocke:laterabbit_2.11:0.3, org.mongodb:casbah-gridfs_2.11:2.8.2, co.blocke:scalajack_2.11:4.4.1, com.typesafe.akka:akka-slf4j_2.11:2.4.0, org.monifu:monifu-core_2.11:0.7.0, org.mongodb:casbah-core_2.11:2.8.2, com.cof:common_2.11:reactive2_a6d8f9, com.typesafe.akka:akka-http-core-experimental_2.11:1.0, com.typesafe.akka:akka-actor_2.11:2.4.0, org.scala-lang:scala-reflect:2.11.7 (), org.mongodb:casbah_2.11:2.8.2, com.typesafe.akka:akka-parsing-experimental_2.11:1.0, org.mongodb:casbah-commons_2.11:2.8.2, org.mongodb:casbah-query_2.11:2.8.2, co.blocke:scalajack_mongo_2.11:4.4.1, com.thenewmotion.akka:akka-rabbitmq_2.11:1.2.4)
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[success] Total time: 1 s, completed Oct 23, 2015 5:57:30 PM
答案 0 :(得分:0)
为避免歧义,您可以添加sender()
或ActorRef.noSender
- 取决于上下文。或者添加超时mongoControl.ask(MongoAction({...}))(1.second)