2016-03-15 49 views
6

我有一個播放框架應用,2.4版本遷移到2.5,一切搞定!但拋出一個錯誤,在我的自定義操作與BodyParser播放2.5遷移錯誤:與BodyParser自定義操作:找不到參數墊內含價值:akka.stream.Materializer

def isAuthenticatedAsync[A](parser: BodyParser[A])(f: => Long => Request[A] => Future[Result]) = { 
Security.Authenticated(userId, onUnauthorized) { user => 
    Action.async(parser)(request => f(user)(request)) 
} 

}

使用此:

def upload = isAuthenticatedAsync(parse.maxLength(5 * 1024 * 1024, parse.multipartFormData)) { userId => request => 
//Logger.info(s"") 
request.body match { 
    case Left(MaxSizeExceeded(length)) => Future(BadRequest(Json.toJson(ResultTemp("Your file is too large, we accept just " + length + " bytes!")))) 
    case Right(multipartForm) => 

拋出一個錯誤:

could not find implicit value for parameter mat: akka.stream.Materializer 

[錯誤]高清upload = Action.async(parse.maxLength(5 * 1024 * 1024,parse.multipartFormDa TA)){請求=>

回答

6

看起來你需要注入materializer在控制器

class MyController @Inject() (implicit val mat: Materializer) {} 
+0

非常感謝你! –

+0

不用客氣@ĐạtThành。享受Scala。 –