我正在尝试设置一个与本地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]]
我发现,我的游戏2.4不需要hikari作为明确的依赖。附加密码和用户名都是正确的以及databsename。
除了框架网站之外,我实际上并不知道在哪里寻找更多信息,我已经广泛检查过了。多人似乎也有类似的问题,虽然他们的解决方案对我没有帮助,或者只是我走这条路的一步。
答案 0 :(得分:3)
有两个地方可以确切地了解如何配置连接池:
reference.conf
file 从那里,您可以看到您的游泳池必须配置为:
db {
default {
driver=org.postgresql.Driver
url="jdbc:postgresql://localhost/timeseries"
user=postgres
password=postgres
hikaricp {
dataSourceClassName = org.postgresql.ds.PGSimpleDataSource
connectionTestQuery = "SELECT 1"
# Data source configuration options. Must be INSIDE
# the hikaricp "node" here
dataSource {
# anything you need to configure here
...
}
}
}
}
注意配置节点是如何嵌套的:db
- &gt; default
- &gt; hikaricp
- &gt; dataSource
。这是因为dataSource
是HikariCP特有的配置。正如您在reference.conf
文件中看到的,BoneCP不提供此配置节点。
此外,Typesafe Configuration library同时支持上述配置或写出更多&#34;明显&#34;如下所示:
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost/timeseries"
db.default.user=postgres
db.default.password=postgres
db.default.hikaricp.dataSourceClassName = org.postgresql.ds.PGSimpleDataSource
db.default.hikaricp.connectionTestQuery = "SELECT 1"
答案 1 :(得分:1)
还可以尝试:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<a href="#" class="niva3" data-target="#get1">Link 1</a>
<a href="#" class="niva3" data-target="#get2">Link 2</a>
<a href="#" class="niva3" data-target="#get3">Link 3</a>
<div class="niva3-dolj" id="get1">[include id="1365"]</div>
<div class="niva3-dolj" id="get2">[include id="1562"]</div>
<div class="niva3-dolj" id="get3">[include id="1565"]</div>
答案 2 :(得分:0)
找到答案:
您需要使用以下格式:
dataSourceClassName=org.postgresql.ds.PGSimpleDataSource
dataSource.user=postgres
dataSource.password=sdfsdfasd
dataSource.databaseName=timeseries
dataSource.serverName=localhost
hikaricp .connectionTestQuery = "SELECT 1"