2014-07-07 55 views
1

我有一齣戲控制器下面的代碼:播放AsyncResult的輔助工作不

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 [結果]構建一個AsyncResult。」

但是到目前爲止,我還沒有能夠在play.api._中找到Async或AsyncResult,我的代碼出現了什麼問題,以及哪一個是獲取AsyncResult句柄的正確導入?

回答

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,特別是結果重組部分。