我目前正在尝试将项目从Play 2.5迁移到Play 2.6,并已阅读此docs以迁移消息API。我仍然收到错误:
An implicit Messages instance was not found.
尝试创建这样的自定义错误处理程序时:
class ErrorHandler @Inject()(
env: Environment,
conf: Configuration,
sourceMapper: OptionalSourceMapper,
router: Provider[Router],
override val messagesApi: MessagesApi
) extends DefaultHttpErrorHandler(env, conf, sourceMapper, router) with I18nSupport {
// ...
}
答案 0 :(得分:0)
特征I18nSupport
将能够提供Messages
个实例。但为此,它的范围需要implicit request
:
implicit def request2Messages(implicit request: RequestHeader): Messages
确保您的请求标记为implicit