2017-06-21 37 views
1

試圖按照從斯卡拉遷移指南發揮框架2.6版本來自: https://playframework.com/documentation/2.6.x/Highlights26斯卡拉播放單元測試控制器的2.6.x - 封裝併發目標執行已被棄用:請參閱2.6遷移指南

和升級後我的測試突破:

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 

這是我的控制器declar通貨膨脹:

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

和我注射執行上下文「的ExecutionContext:scala.concurrent.ExecutionContext」

我下面正式打出框架2.6的例子,但仍試驗不扔編制上述錯誤味精。

回答

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