1

尝试遵循 Scala 播放框架 2.6 版的迁移指南: https ://playframework.com/documentation/2.6.x/Highlights26

升级后我的测试失败了:

val controller = new ProductController(stubControllerComponents().asInstanceOf[ProductControllerComponents])

我得到:

> object Execution in package concurrent is deprecated: Please see
> https://www.playframework.com/documentation/2.6.x/Migration26#Execution

这是我的控制器声明:

class ProductController @Inject()(cc: ProductControllerComponents)(implicit ec: ExecutionContext)
    extends ProductBaseController(cc)

我注入的执行上下文是“executionContext:scala.concurrent.ExecutionContext”

我正在关注官方播放框架 2.6 示例,但仍然测试未编译并抛出上面的错误消息。

4

1 回答 1

0

playframework/framework/src/play/src/main/scala/play/api/mvc/Controller.scala

  /**
   * The default execution context provided by Play. You should use this for non-blocking code only. You can do so by
   * passing it explicitly, or by defining an implicit in your controller like so:
   *
   * {{{
   *   implicit lazy val executionContext = defaultExecutionContext
   * }}}
   */
  def defaultExecutionContext: ExecutionContext = controllerComponents.executionContext
于 2017-06-22T07:50:08.337 回答