我刚刚更新到Play 2.5.2,我的过滤器(在Login上运行)给出了以下错误:
ProvisionException: Unable to provision, see the following errors:
1) Error injecting constructor, java.lang.RuntimeException: There is no started application
at filters.LoginFilter.<init>(LoginFilter.scala:15)
我不得不稍微修改我的代码以匹配由2.5.2设置为Filter的新更改:
import akka.stream.Materializer
import com.google.inject.Inject
import play.api.Play._
import play.api.cache.CacheApi
import play.api.mvc.Results._
import play.api.mvc.{Filter, RequestHeader, Result}
import scala.concurrent.{ExecutionContext, Future}
class LoginFilter @Inject() (implicit val mat: Materializer, ec: ExecutionContext) extends Filter {
}
我必须添加带有Materializer的@Inject,否则我会收到一条错误消息,指出该类应该是抽象的,或者应该实现Materializer。
我该如何解决这个问题?谢谢!
答案 0 :(得分:1)
I'm actually not sure about this one and honestly I don't know the difference but in all my files there is the javax.inject not the google inject, so it might be worth a try.
Instead of:
import com.google.inject.Inject
try:
import javax.inject.Inject