gpt4 book ai didi

scala - Play 2.5 迁移错误 : Custom Action with BodyParser: could not find implicit value for parameter mat: akka. stream.Materializer

转载 作者:行者123 更新时间:2023-12-04 11:49:31 26 4
gpt4 key购买 nike

我有一个 Play Framework 应用程序,版本 2.4 迁移到 2.5 ,一切都搞定了!但使用 在我的自定义操作中引发错误 body 解析器 ,

 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

[错误] def upload = Action.async(parse.maxLength(5 * 1024 * 1024, parse.multipartFormData)) { request =>

最佳答案

看起来你需要在你的 Controller 中注入(inject)一个物化器

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

关于scala - Play 2.5 迁移错误 : Custom Action with BodyParser: could not find implicit value for parameter mat: akka. stream.Materializer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36004414/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com