Dropwizard 在 Heroku 上崩溃
Dropwizard crashing on Heroku
我正在尝试将我的 Dropwizard 项目部署到 Heroku。
我已将 Procfile 和 Postgres DB 添加到 Heroku 应用程序。
我的 Procfile 显示:
web: java $JAVA_OPTS -Ddw.server.connector.port=$PORT -Ddw.database.url=$DATABASE_URL -jar target/api-1.0-SNAPSHOT.jar server config.yml
当我尝试部署时,我在日志中收到以下 error/crash 消息。
org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator: HHH000342: Could not obtain connection to query metadata : Driver:org.postgresql.Driver@53d13cd4 returned null for URL:postgres://fdeqzbddzbefaz:138912590e989b1b8fab5d169a1aea291f04b2d3bc040b1bbf6642a9207a5355@ec2-54-235-101-91.compute-1.amazonaws.com:5432/d67crr4pvqrfee
Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
State changed from starting to crashed
Process exited with status 1
我的config.yml读
database:
# the name of your JDBC driver
driverClass: org.postgresql.Driver
# the username
user: localusername
# the JDBC URL
url: jdbc:postgresql://localhost/dbname
# use the simple server factory if you only want to run on a single port
# HEROKU NOTE - the port gets be overridden with the Heroku $PORT in the Procfile
server:
type: simple
applicationContextPath: /
#adminContextPath: /admin # If you plan to use an admin path, you'll need to also use non-root app path
connector:
type: http
port: 8080
有没有人有解决问题的想法?
DATABASE_URL
env var 不直接兼容 JDBC URL 格式。参见 docs。具体来说,
The DATABASE_URL for the Heroku Postgres add-on follows the below convention
postgres://username:password@host:port/dbname
However the Postgres JDBC driver uses the following convention:
jdbc:postgresql://host:port/dbname?user=username&password=password
相反,尝试使用 JDBC_DATABASE_URL
作为记录 here
我正在尝试将我的 Dropwizard 项目部署到 Heroku。
我已将 Procfile 和 Postgres DB 添加到 Heroku 应用程序。 我的 Procfile 显示:
web: java $JAVA_OPTS -Ddw.server.connector.port=$PORT -Ddw.database.url=$DATABASE_URL -jar target/api-1.0-SNAPSHOT.jar server config.yml
当我尝试部署时,我在日志中收到以下 error/crash 消息。
org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator: HHH000342: Could not obtain connection to query metadata : Driver:org.postgresql.Driver@53d13cd4 returned null for URL:postgres://fdeqzbddzbefaz:138912590e989b1b8fab5d169a1aea291f04b2d3bc040b1bbf6642a9207a5355@ec2-54-235-101-91.compute-1.amazonaws.com:5432/d67crr4pvqrfee
Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
State changed from starting to crashed
Process exited with status 1
我的config.yml读
database:
# the name of your JDBC driver
driverClass: org.postgresql.Driver
# the username
user: localusername
# the JDBC URL
url: jdbc:postgresql://localhost/dbname
# use the simple server factory if you only want to run on a single port
# HEROKU NOTE - the port gets be overridden with the Heroku $PORT in the Procfile
server:
type: simple
applicationContextPath: /
#adminContextPath: /admin # If you plan to use an admin path, you'll need to also use non-root app path
connector:
type: http
port: 8080
有没有人有解决问题的想法?
DATABASE_URL
env var 不直接兼容 JDBC URL 格式。参见 docs。具体来说,
The DATABASE_URL for the Heroku Postgres add-on follows the below convention
postgres://username:password@host:port/dbname
However the Postgres JDBC driver uses the following convention:
jdbc:postgresql://host:port/dbname?user=username&password=password
相反,尝试使用 JDBC_DATABASE_URL
作为记录 here