我正在尝试配置 jhipster 以使用 heroku 的 postgres 数据库。以下是我的数据库参数以及经过编辑的凭据:
spring:
profiles: dev
datasource:
dataSourceClassName: org.postgresql.ds.PGSimpleDataSource
url:
databaseName: xxxx
serverName: ec2-54-225-182-133.compute-1.amazonaws.com
username: xxxx
password: xxxx
它导致这个错误,我确定是因为我需要启用 SSL:
[DEBUG] com.john_g_shultz.site.config.DatabaseConfiguration - Configuring Datasource
[ERROR] com.zaxxer.hikari.HikariPool - Maximum connection creation retries exceeded: FATAL: no pg_hba.conf entry for host "72.69.103.36", user "xxxxxx", database "xxxxxx", SSL off
根据heroku,远程数据库连接需要带有两个SSL参数的JDBC连接URL。我无法成功配置此 URL。
Connecting to a database remotely
If you’re using a Heroku Postgres database you can connect to it remotely for maintenance and debugging purposes. However doing so requires that you use an SSL connection. Your JDBC connection URL will need to include the following: ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
最佳答案
我想出了如何格式化远程 postgres 连接的凭据
spring:
profiles: dev
datasource:
dataSourceClassName: org.postgresql.ds.PGSimpleDataSource
url: jdbc:postgresql://HOSTNAME/DATABASENAME?user=xxxx&password=xxxx&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
databaseName:
serverName:
username: xxxx
password: xxxx
关于postgresql - 将 jhipster 远程连接到 postgres,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23727974/