gpt4 book ai didi

postgresql - Grails-Heroku不使用DataSource.groovy中定义的数据库

转载 作者:行者123 更新时间:2023-12-02 16:00:48 26 4
gpt4 key购买 nike

我刚刚按照以下文档将Grails应用程序部署到了Heroku。.https://devcenter.heroku.com/articles/getting-started-with-grails#prerequisites

在部署之前,我创建了一个Dev数据库并将URL详细信息插入DataSource.groovy的生产部分

production {
dataSource {
dbCreate = "update"
//url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
//url = "jdbc:postgresql://localhost:5432/myapp"


uri = new URI(System.env.DATABASE_URL?:"postgres://myuser:mypassword@someAWSmachine:5432/myapp")

url = "jdbc:postgresql://" + uri.host + ":" + uri.port + uri.path
username = uri.userInfo.split(":")[0]
password = uri.userInfo.split(":")[1]

但是,当我取消部署我的应用程序时,它创建了另一个开发数据库并将此新数据库的URL信息设置为 Settings-> Config Variables-> DATABASE_URL
我的应用程序以某种方式运行并正在使用这个新创建的数据库及其设置,我的问题是如何?为什么我的应用程序无法运行,因为我在 DataSource.groovy中配置了另一个数据库URL?

最佳答案

糟糕...我第一次阅读时并没有完全消化这行
uri = new URI(System.env.DATABASE_URL?:"postgres://myuser:mypassword@someAWSmachine:5432/myapp")
注意System.env.DATABASE_URL?三元运算符。

我会把这个问题留给别人

关于postgresql - Grails-Heroku不使用DataSource.groovy中定义的数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31278537/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com