【发布时间】:2016-01-21 13:53:45
【问题描述】:
我正在尝试设置一个连接到本地 postgres 的播放框架服务器。
我现在的applications.conf是这样的:
dbplugin=disabled
db {
default {
dataSourceClassName=org.postgresql.ds.PGSimpleDataSource
dataSource {
user="postgres"
password="postgres"
databaseName="timeseries"
serverName="localhost"
}
hikaricp {
connectionTestQuery = "SELECT 1"
}
}
}
我的 build.sbt 只添加了用于 postgres 的最新 jdbc:
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.6"
libraryDependencies ++= Seq(
javaJdbc
, cache
, javaWs
, "org.postgresql" % "postgresql" % "9.4.1207.jre7"
)
我收到的错误是
[error] - application -
[info]
[info] ! @6ookeg34l - Internal server error, for (GET) [/] ->
[info]
[info] play.api.UnexpectedException: Unexpected exception[CreationException: Unable to create injector, see the following errors:
[info]
[info] 1) Error in custom provider, Configuration error: Configuration error[Cannot connect to database [default]]
[info] while locating play.api.db.DBApiProvider
[info] while locating play.api.db.DBApi
[info] for parameter 0 at play.db.DefaultDBApi.<init>(DefaultDBApi.java:28)
[info] at play.db.DefaultDBApi.class(DefaultDBApi.java:28)
[info] while locating play.db.DefaultDBApi
[info] while locating play.db.DBApi
[info] for field at play.db.DBModule$NamedDatabaseProvider.dbApi(DBModule.java:61)
[info] while locating play.db.DBModule$NamedDatabaseProvider
[info] at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:149)
[info] at play.db.DBModule.bindings(DBModule.java:40):
[info] Binding(interface play.db.Database qualified with QualifierInstance(@play.db.NamedDatabase(value=default)) to ProviderTarget(play.db.DBModule$NamedDatabaseProvider@3782a5cb)) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
[info] Caused by: Configuration error: Configuration error[Cannot connect to database [default]]
我发现,我的 play 2.4 不需要 hikari 作为明确的依赖。另外密码和用户名以及数据库名称都是正确的。
除了框架的网站之外,我实际上不知道在哪里可以找到更多信息,我已经广泛检查了这两个信息。很多人似乎都遇到过类似的问题,尽管他们的解决方案对我没有帮助,或者只是我到目前为止的一步。
【问题讨论】:
标签: java postgresql playframework datasource hikaricp