我是使用 DI 的初学者,在将我的应用程序从 play java 2.3 迁移到 2.4.2 时遇到了一些问题。
顺便说一句,如果有一些模板适合像计算机基础应用程序一样 Play java 2.4.x,那就太好了。
当我创建一个全新的新应用程序时,我无法让 Play Ebean 插件正常工作。
作为指示我添加:Play Ebean 插件 tin project/plugins.sbt:
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")
然后在 build.sbt 中:
lazy val myProject = (project in file(".")).enablePlugins(PlayJava, PlayEbean)
在 application.conf 中:
ebean.default = ["models.*"]
默认数据库是postgresql
它可以编译,但是当我运行应用程序时出现以下错误:
Error in custom provider, Configuration error: Configuration error[null]
while locating play.db.ebean.DefaultEbeanConfig$EbeanConfigParser
at play.db.ebean.EbeanModule.bindings(EbeanModule.java:24):
Binding(interface play.db.ebean.EbeanConfig to
ProviderConstructionTarget(class
play.db.ebean.DefaultEbeanConfig$EbeanConfigParser) eagerly) (via
modules: com.google.inject.util.Modules$OverrideModule ->
play.api.inject.guice.GuiceableModuleConversions$$anon$1)
while locating play.db.ebean.EbeanConfig
for parameter 0 at
play.db.ebean.EbeanDynamicEvolutions.<init>(EbeanDynamicEvolutions.java:36)
....
Caused by: Configuration error: Configuration error[null]
......
Caused by: java.lang.NullPointerException at play.db.ebean.DefaultEbeanConfig$EbeanConfigParser.parse(DefaultEbeanConfig.java:79)
完整的轨迹就是这条:http://pastebin.com/7DtjSPFA
怎么了?是否需要更多配置?
感谢您的帮助。
最佳答案
感谢您的回复。最后我解决了,问题出在conf/application.conf
中的数据库连接配置:
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/mydb"
db.default.username="user"
db.default.password="password"
我的错,我在配置连接池 HikariCP(play.db.prototype.driver 等...)时修改了它,因此数据库连接正常但 Ebean 不可用。
关于java - 玩2.4.2 java中的Ebean配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31893184/