gpt4 book ai didi

java - 玩!框架 2.7 - 无法连接到数据库

转载 作者:行者123 更新时间:2023-12-01 16:35:00 24 4
gpt4 key购买 nike

我正在尝试从我的 play 2.7 应用程序连接到我的 postgres 数据库。数据库是一个使用

初始化的 docker 镜像
docker run -d --name backend_local - p 127.0.0.1:5432:5432 -e POSTGRES_USER=markos -e POSTGRES-PASSWORD=**** -e POSTGRES_DB=backend_db --restart always registry.gitlab....

我的配置文件如下所示

# Database
db.default.driver=org.postgresql.jdbc.Driver
db.default.url="jdbc:postgresql://localhost:5432/backend_db"
db.default.username="markos"
db.default.password="****"
db.default.logSql=true

看不到连接有问题,但我仍然遇到无法初始化数据库[默认]

我收到的日志

2020-05-23 15:44:13.044+0200 [error] application - 

! @7fpl591k9 - Internal server error, for (GET) [/] ->

play.api.Configuration$$anon$1: Configuration error[Cannot initialize to database [default]]
at play.api.Configuration$.configError(Configuration.scala:168)
at play.api.Configuration.reportError(Configuration.scala:1014)
at play.api.db.DefaultDBApi.$anonfun$initialize$1(DefaultDBApi.scala:76)
at scala.collection.immutable.List.foreach(List.scala:389)
at play.api.db.DefaultDBApi.initialize(DefaultDBApi.scala:68)
at play.api.db.DBApiProvider.get$lzycompute(DBModule.scala:93)
at play.api.db.DBApiProvider.get(DBModule.scala:77)
at play.api.db.DBApiProvider.get(DBModule.scala:59)
at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:85)
at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:77)
Caused by: play.api.Configuration$$anon$1: Configuration error[dataSource or dataSourceClassName or jdbcUrl is required.]
at play.api.Configuration$.configError(Configuration.scala:168)
at play.api.Configuration.reportError(Configuration.scala:1014)
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:68)
at play.api.db.PooledDatabase.createDataSource(Databases.scala:248)
at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:140)
at play.api.db.DefaultDatabase.dataSource(Databases.scala:138)
at play.api.db.DefaultDBApi.$anonfun$initialize$1(DefaultDBApi.scala:72)
at scala.collection.immutable.List.foreach(List.scala:389)
at play.api.db.DefaultDBApi.initialize(DefaultDBApi.scala:68)
at play.api.db.DBApiProvider.get$lzycompute(DBModule.scala:93)
Caused by: java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required.
at com.zaxxer.hikari.HikariConfig.validate(HikariConfig.java:958)
at play.api.db.HikariCPConfig.toHikariConfig(HikariCPModule.scala:138)
at play.api.db.HikariCPConnectionPool.$anonfun$create$1(HikariCPModule.scala:55)
at scala.util.Try$.apply(Try.scala:209)
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:52)
at play.api.db.PooledDatabase.createDataSource(Databases.scala:248)
at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:140)
at play.api.db.DefaultDatabase.dataSource(Databases.scala:138)
at play.api.db.DefaultDBApi.$anonfun$initialize$1(DefaultDBApi.scala:72)
at scala.collection.immutable.List.foreach(List.scala:389)

最佳答案

似乎我处理数据库配置的 local_dev.conf 被放错了位置,远离了原来应该位于的conf 文件!

关于java - 玩!框架 2.7 - 无法连接到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61973116/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com