如你所知,玩吧! 2.2.0版本中的introduced Gzip encoding 不幸的是,在更新项目和更新游戏后,它不起作用。
[error] ...\app\Global.scala:4: object filters is not a member of package play
[error] import play.filters.gzip.GzipFilter
[error] ^
[error] ...\app\Global.scala:8: not found: type GzipFilter
[error] object Global extends WithFilters(new GzipFilter) with GlobalSettings {
[error] ^
[error] two errors found
[error] (compile:compile) Compilation failed
即使我创建项目表单控制台play new TEST
,它也不起作用。
但是在C:\play-2.2.0\framework\src\play-filters-helpers\src\main\scala\play\filters\gzip
我同时拥有Gzip.scala
和GzipFilter.scala
。
我的\app\Global.scala
看起来像这样:
import play.api._
import play.api.mvc._
import play.api.mvc.Results._
import play.filters.gzip.GzipFilter
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
object Global extends WithFilters(new GzipFilter) with GlobalSettings {
override def onStart(app: Application) {
Logger.info("Application has started")
}
override def onStop(app: Application) {
Logger.info("Application shutdown")
}
override def onError(request: RequestHeader, ex: Throwable) = Future { InternalServerError("{}") }
override def onBadRequest(request: RequestHeader, error: String) = Future { BadRequest("{}") }
override def onHandlerNotFound(request: RequestHeader) = Future { NotFound("{}") }
}
我做错了什么?有人做过这个吗?
答案 0 :(得分:16)
在 Build.scala 中,只需在应用依赖项中添加“过滤器”
val appDependencies = Seq(
jdbc, cache, filters, ...
)
或者,如果您使用 build.sbt
进行此操作libraryDependencies ++= Seq(
jdbc, cache, filters, ...
)