2

我正在尝试配置 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。

远程连接到数据库

如果您使用的是 Heroku Postgres 数据库,您可以远程连接到它以进行维护和调试。但是,这样做需要您使用 SSL 连接。您的 JDBC 连接 URL 需要包含以下内容:ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

4

1 回答 1

2

我想出了如何格式化远程 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
于 2014-05-21T17:53:25.883 回答