scala - 如何修复 Scala (Akka 2.4.0) 中被逐出的库和不明确的引用错误?

标签 scala akka

我有使用新 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

最佳答案

为避免歧义,您可以添加 sender()ActorRef.noSender - 取决于上下文。或者添加超时 mongoControl.ask(MongoAction({...}))(1.second)

关于scala - 如何修复 Scala (Akka 2.4.0) 中被逐出的库和不明确的引用错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33312673/

相关文章:

scala - Scala 是否具有用于制作不可变数据结构的修改克隆的记录更新语法?

java - Play! 框架和 Akka 讲述

java - Eclipse 无法解析 maven 项目中的 akka 引用

scala - 不变性和内存使用

scala - 堆叠特征中 super 的含义取决于调用站点?

scala - 使用 Slick 重构期间的类型不匹配

scala - 未检查,因为它已被删除消除

java - Patterns.ask 超时后消息将转到哪里?

docker - Docker + Alpine Linux上的Akka 2.5分布式数据

scala - partition 和 groupBy 有什么区别?