播放AsyncResult助手无法正常工作

时间:2014-07-07 18:05:58

标签: scala playframework akka

我在播放控制器中有以下代码:

object Application extends Controller {

  def index = Action {
    Async {
        Ok(views.html.index("Your new application is ready."))
    }
  }
}

问题在于,当我运行时:./activator compile我收到此错误:

...       not found: value Async
[error]     Async {
[error]     ^
[error] one error found
[error] (compile:compile) Compilation failed
[error] Total time: 6 s, completed 07-jul-2014 13:28:59

在文档中,它说:

“注意:Async {}是一个帮助方法,它从Promise [Result]构建AsyncResult。”

但到目前为止,我还没能在play.api中找到Async和AsyncResult._我的代码有什么问题,哪些是正确的导入来获取AsyncResult的句柄?

1 个答案:

答案 0 :(得分:1)

AsyncResult(以及除SimpleResult之外的所有其他结果)在Play 2.2中已弃用,随后在Play 2.3中删除,仅保留Result。请改用Action.async

def index = Action.async {
    Ok(views.html.index("Your new application is ready."))
}

有关其他信息,请参阅Play 2.3 Migration Guide,尤其是结果重组部分。

相关问题