我想将我的grails应用程序部署到heroku。
我已经创建了一个堆栈,现在到了想要推送它的阶段:git push heroku master
然而,我收到的是:
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
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中获取完整的堆栈跟踪?
发布于 2014-05-18 17:43:10
URI Class采用[user-info@]host[:port]语法,您提供了电子邮件地址,而电子邮件地址本身具有@符号,这就是为什么uri.host和uri.userInfo为空,构建会失败。
尝试打印uri.host和uri.userInfo,您可以看到它们都是空的。在数据源中添加以下代码
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作为密码。像这样:
uri = new URI(System.env.DATABASE_URL ?: "postgres://test:pass@5432/TestDB")而且它是有效的。
https://stackoverflow.com/questions/23651564
复制相似问题