我的项目最近从Play 2.5更新到2.6.13。 我添加了一个新脚本16.sql,但更改未应用于表 play_evolutions
根据documentation 2.6,如果使用编译时间DI,则必须注入EvolutionsComponents
。但是Guice是运行时DI,因此我不必注入任何组件。
我启用了build.sbt
libraryDependencies ++= Seq(evolutions, jdbc)
在application.conf中
play.evolutions.enabled=true
play.evolutions.autoApply=true
我的项目缺少什么?欢迎使用任何git示例
答案 0 :(得分:0)
自升级到Play 2.6以来,我通过遵循the documentation解决了问题
这是我的代码
import play.api.ApplicationLoader.Context
import play.api.{Application, ApplicationLoader, BuiltInComponentsFromContext}
import play.api.db.{DBComponents, HikariCPComponents}
import play.api.db.evolutions.EvolutionsComponents
import play.api.routing.Router
import play.filters.HttpFiltersComponents
import router.Routes
class MyApplicationLoader extends ApplicationLoader {
def load(context: ApplicationLoader.Context): Application = {
new AppComponents(context).application
}
}
class AppComponents(context: Context)
extends BuiltInComponentsFromContext(context)
with DBComponents
with EvolutionsComponents
with HikariCPComponents
with HttpFiltersComponents {
// this will actually run the database migrations on startup
applicationEvolutions
// val prefix: String = "/"
lazy val router = Router.empty
// lazy val router: Router = bind(classOf[Routes]).to(classOf[Routes])
}
然后在conf / application.conf中添加此行
play.application.loader=MyApplicationLoader