我尝试按照官方迁移指南将Play 2.4.6项目迁移到Play 2.5.8:https://www.playframework.com/documentation/2.5.x/Migration25
数据库成功连接后,我收到以下错误消息(Full Stacktrace):
[info] p.a.d.DefaultDBApi - Database [default] connected at XXX;
[error] application -
! @71in3ncdp - Internal server error, for (GET) [/de] ->
play.api.UnexpectedException: Unexpected exception[CreationException: Unable to create injector, see the following errors:
1) Error in custom provider, java.lang.NullPointerException
while locating play.api.db.evolutions.ApplicationEvolutionsProvider
at play.api.db.evolutions.EvolutionsModule.bindings(EvolutionsModule.scala:22):
Binding(class play.api.db.evolutions.ApplicationEvolutions to ProviderConstructionTarget(class play.api.db.evolutions.ApplicationEvolutionsProvider) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
while locating play.api.db.evolutions.ApplicationEvolutions
1 error]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:180)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:131)
at scala.Option.map(Option.scala:146)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:131)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:129)
at scala.util.Success.flatMap(Try.scala:231)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:129)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:121)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
Caused by: com.google.inject.CreationException: Unable to create injector, see the following errors:
1) Error in custom provider, java.lang.NullPointerException
while locating play.api.db.evolutions.ApplicationEvolutionsProvider
at play.api.db.evolutions.EvolutionsModule.bindings(EvolutionsModule.scala:22):
Binding(class play.api.db.evolutions.ApplicationEvolutions to ProviderConstructionTarget(class play.api.db.evolutions.ApplicationEvolutionsProvider) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
while locating play.api.db.evolutions.ApplicationEvolutions
1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:466)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:184)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:84)
at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:168)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:164)
Caused by: java.lang.NullPointerException: null
at com.avaje.ebean.config.dbplatform.DatabasePlatform.createDdlHandler(DatabasePlatform.java:209)
at com.avaje.ebean.dbmigration.model.CurrentModel.handler(CurrentModel.java:150)
at com.avaje.ebean.dbmigration.model.CurrentModel.createDdl(CurrentModel.java:141)
at com.avaje.ebean.dbmigration.model.CurrentModel.getCreateDdl(CurrentModel.java:107)
at play.db.ebean.EbeanDynamicEvolutions.generateEvolutionScript(EbeanDynamicEvolutions.java:93)
at play.db.ebean.EbeanDynamicEvolutions.lambda$create$4(EbeanDynamicEvolutions.java:59)
at java.util.HashMap.forEach(HashMap.java:1280)
at play.db.ebean.EbeanDynamicEvolutions.create(EbeanDynamicEvolutions.java:58)
at play.api.db.evolutions.ApplicationEvolutions.start(ApplicationEvolutions.scala:40)
at play.api.db.evolutions.ApplicationEvolutions.<init>(ApplicationEvolutions.scala:150)
奇怪的是,我没有使用Play Evolutions,我甚至在application.conf中禁用了它:
play.evolutions.enabled=false
答案 0 :(得分:6)
我自己刚刚解决了这个问题。
必须使用配置文件中的附加行禁用Evolutions模块,所以我现在在application.conf中有这两行:
play.evolutions.enabled=false
play.modules.disabled += "play.api.db.evolutions.EvolutionsModule"
我真的不明白为什么需要这个以及为什么它没有记录在https://www.playframework.com/documentation/2.5.x/Evolutions
中希望将来可以帮助某人。