【发布时间】:2015-01-19 15:06:14
【问题描述】:
我正在关注 akka-in-action 教程,在第 2 章中,有一个类 (https://github.com/RayRoestenburg/akka-in-action/blob/master/chapter2/src/main/scala/com/goticks/RestInterface.scala):
trait RestApi extends HttpService with ActorLogging { actor: Actor =>
import context.dispatcher
import com.goticks.TicketProtocol._
...
import context.dispatcher 从未使用过,但它是用注释定义的:
/**
* Returns the dispatcher (MessageDispatcher) that is used for this Actor.
* Importing this member will place an implicit ExecutionContext in scope.
*/
implicit def dispatcher: ExecutionContextExecutor
但是,IntelliJ 一直将导入标记为“未使用”并在“优化导入”时将其删除,从而导致错误 value pipeTo is not a member of scala.concurrent.Future[Any]。
有没有办法告诉 IntelliJ 这个导入不是为了“使用”,而只是提供一个上下文?
或者应该更新教程以不使用这种“未使用的导入”?
【问题讨论】:
-
Intellij 的“优化导入”功能有问题。我倾向于在设置中关闭删除未使用的导入,只使用它来添加新的导入。
-
不。这不是关于禁用删除未使用包的所有导入,而是关于禁用删除“使用”但 IDEA 认为它们“未使用”的导入。
-
我是否需要编辑问题以消除“重复备注”框?
标签: scala intellij-idea akka executioncontext