我想为我的Play应用配置Postgresql,但是我收到以下错误:
! Internal server error,for request [GET /] -> java.util.concurrent.TimeoutException: Futures timed out after [300000] milliseconds at akka.dispatch.DefaultPromise.ready(Future.scala:834) ~[akka-actor.jar:2.0] at akka.dispatch.DefaultPromise.result(Future.scala:838) ~[akka-actor.jar:2.0] at akka.dispatch.Await$.result(Future.scala:74) ~[akka-actor.jar:2.0] at play.core.ReloadableApplication.get(ApplicationProvider.scala:108) ~[play_2.9.1.jar:2.0] at play.core.server.Server$class.sendHandler$1(Server.scala:59) [play_2.9.1.jar:2.0] at play.core.server.Server$$anonfun$getHandlerFor$4.apply(Server.scala:89) [play_2.9.1.jar:2.0] [error] application - ! @6a64i2p5o - Internal server error,for request [GET /] -> play.api.PlayException: Not initialized [?] at play.api.PlayException$.apply(Exceptions.scala:122) ~[play_2.9.1.jar:2.0] at play.core.ReloadableApplication.<init>(ApplicationProvider.scala:94) ~[play_2.9.1.jar:2.0] at play.core.server.NettyServer$$anonfun$mainDev$1.apply(NettyServer.scala:165) ~[play_2.9.1.jar:2.0] at play.core.server.NettyServer$$anonfun$mainDev$1.apply(NettyServer.scala:164) ~[play_2.9.1.jar:2.0] at play.utils.Threads$.withContextClassLoader(Threads.scala:17) ~[play_2.9.1.jar:2.0] at play.core.server.NettyServer$.mainDev(NettyServer.scala:163) ~[play_2.9.1.jar:2.0]
我使用以下配置文件:
application.conf
db.default.url="postgres://play:play@localhost:9000/Play_Playground_DB" db.default.user=play db.default.password=play db.default.driver=org.postgresql.Driver
项目/ Build.scala
val appDependencies = Seq( "postgresql" % "postgresql" % "9.1-901.jdbc4" )
我设置了Play_Playground_DB,可以通过终端和psql Play_Playground_DB命令进行访问.
可能是这个问题的根本原因?
很可能这是问题:
db.default.url="postgres://play:play@localhost:9000/Play_Playground_DB"
play doku说,“db.default.url”是一个简单的JDBC-URL.你的价值有两个问题:
>它不是Postgresql承认的格式.查看here的允许格式.
>使用…默认值…您重新定义默认数据源.默认情况下,除非您再执行一些步骤,否则这将会产生麻烦.
在您的情况下,有效的Postgresql URL可能如下所示:
jdbc:postgresql://localhost:9000/Play_Playground_DB
但是:_确保您的数据库在端口9000上运行?你说psql Play_Playground_DB适合你.所以我认为你的端口应该是默认端口5432.然后这个URL是正确的:
jdbc:postgresql://localhost/Play_Playground_DB