我正在尝试将我的Dropwizard项目部署到Heroku。
我在Heroku应用程序中添加了一个Procfile和一个Postgres数据库。 我的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
当我尝试部署时,我在日志中收到以下错误/崩溃消息。
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
有没有人在拍摄创意时遇到任何麻烦?
答案 0 :(得分:1)
DATABASE_URL
env var与JDBC URL格式不直接兼容。见docs。具体地,
Heroku Postgres附加组件的DATABASE_URL遵循以下惯例
postgres的://用户名:密码@主机:端口/ DBNAME
然而,Postgres JDBC驱动程序使用以下约定:
JDBC:在PostgreSQL://主机:端口/ DBNAME用户=用户名和安培;密码=密码
相反,请尝试使用JDBC_DATABASE_URL
<{3}}