玩框架+ Heroku + Postgres无法连接 [英] Play Framework + Heroku + Postgres not able to connect
问题描述
配置游戏的正确方法是什么! 2.0应用程序连接到一个heroku提供的Postgres实例?
我尝试了以下变体:
PLAY_OPTS = - Ddb.default.url = $ DATABASE_URL -Ddb.default.driver = org.postgresql .Driver
但是在启动时,我得到了一个SQLException,显示$ DATABASE_URL中找不到合适的驱动程序。
无需将它们作为系统属性传递,您可以在 application.conf
文件中获取Heroku环境变量
...
db.default.driver = org.postgresql.Driver
db.default.url = $ {DATABASE_URL }
然后在你的 Procfile
web:target / start -Dhttp.port = $ {PORT} $ {JAVA_OPTS} -Dconfig.resource = application.conf
它应该选取 DATABASE_URL
属性Heroku环境。尽管我建议创建一个特定于Heroku环境的配置文件(即heroku-prod.conf),但这仅仅是一个例子。
I've been having a heck of a time getting my Play! framework java app to run on Heroku, and I think I've narrowed it down to the Postgres JDBC driver not liking Heroku's DATABASE_URL parameter because it starts with postgres: and not postgresql:.
What is the proper way to configure a play! 2.0 app to connect to a heroku-provided Postgres instance?
I've tried variations on the following: PLAY_OPTS="-Ddb.default.url=$DATABASE_URL -Ddb.default.driver=org.postgresql.Driver"
But upon startup I get a SQLException that no suitable driver can be found for $DATABASE_URL.
No need to pass them in as system properties you can pickup Heroku environment variables in your application.conf
file
...
db.default.driver=org.postgresql.Driver
db.default.url=${DATABASE_URL}
Then define this in your Procfile
web: target/start -Dhttp.port=${PORT} ${JAVA_OPTS} -Dconfig.resource=application.conf
It should pick up the DATABASE_URL
property for the Heroku environment. Although, I recommend creating a configuration file that is specific for the Heroku environment (i.e. heroku-prod.conf), but this is just an example.
这篇关于玩框架+ Heroku + Postgres无法连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!