首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将grails 2.3.4部署到heroku -加载DataSource.groovy时出错

将grails 2.3.4部署到heroku -加载DataSource.groovy时出错
EN

Stack Overflow用户
提问于 2014-05-14 18:06:05
回答 1查看 524关注 0票数 1

我想将我的grails应用程序部署到heroku。

我已经创建了一个堆栈,现在到了想要推送它的阶段:git push heroku master

然而,我收到的是:

代码语言:javascript
复制
       Done precompiling AST Transformations!
       | Compiling 3 source files
       | Compiling 3 source files.
       | Compiling 3 source files..
       | Compiling 3 source files...
       | Compiling 3 source files....
       | Compiling 3 source files.....
-----> Executing ./grailsw -plain-output -Divy.default.ivy.user.dir=/app/tmp/cac
he war --non-interactive
       |Loading Grails 2.3.4
       |Configuring classpath
       .
       |Environment set to production
       .................................
       |Packaging Grails application
       Precompiling AST Transformations ...
       src /tmp/build_f6c7df12-acc1-407e-84b0-95928c52c3ff/target/work/plugins/p
ostgresql-extensions-0.6.1 /tmp/build_f6c7df12-acc1-407e-84b0-95928c52c3ff/targe
t/classes
       Done precompiling AST Transformations!
       ..
       |Compiling 3 source files
       ..................Error
       |
       Error packaging application: Error loading DataSource.groovy: 1 (Use --st
acktrace to see the full trace)
 !     Failed to build app

 !     Push rejected, failed to compile Grails app

To git@heroku.com:quiet-coast-2715.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:quiet-coast-2715.git'

我想我的数据源坏了,所以我的DataSource.groovy

代码语言:javascript
复制
dataSource {
    pooled = true
    driverClassName = "org.postgresql.Driver"
    dialect = org.hibernate.dialect.PostgreSQLDialect
    username = "admin"
    password = "******"
}

hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
    //    cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
}

// environment specific settings
environments {

//...

    production {
        dataSource {
            dbCreate = "update"
            driverClassName = "org.postgresql.Driver"
            dialect = org.hibernate.dialect.PostgreSQLDialect

            uri = new URI(System.env.DATABASE_URL?:"postgres://myHerokuUsername:myPassoword@5432/TestDB")

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

此外,我还在我的BuildConfig.groovy中添加了:

runtime postgresql:postgresql:8.4-702.jdbc3'

我没有看到我在我的数据源中做错了什么?

非常感谢你的回答!

附言:有什么建议如何在git中获取完整的堆栈跟踪?

EN

回答 1

Stack Overflow用户

发布于 2014-05-18 17:43:10

URI Class采用[user-info@]host[:port]语法,您提供了电子邮件地址,而电子邮件地址本身具有@符号,这就是为什么uri.hosturi.userInfo为空,构建会失败。

尝试打印uri.hosturi.userInfo,您可以看到它们都是空的。在数据源中添加以下代码

代码语言:javascript
复制
dataSource {
  ...
  uri = new URI(System.env.DATABASE_URL ?: "postgres://test@gmail.com:pass@5432/TestDB")
  println "---1---${uri}---${uri.host}---${uri.path}---${uri.userInfo}---"
  url = "jdbc:postgresql://" + uri.host + uri.path
  ...
}

要解决此问题,只需将不包含 @ 符号的任何字符串作为您的用户名和密码。我已将test作为用户名,pass作为密码。像这样:

代码语言:javascript
复制
uri = new URI(System.env.DATABASE_URL ?: "postgres://test:pass@5432/TestDB")

而且它是有效的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23651564

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档