由于我已经从Amazon Elastic Beanstalk环境变量获取了数据库主机名,名称,用户名和密码,我自信地尝试对DBCP池属性(maxActive,initialSize,...)执行相同的操作:
(我当前的用例是AWS,但这个问题与AWS无关)
// get some properties from Amazon Elastic Beanstalk environment variables
def rdsHostname = System.getProperty("RDS_HOSTNAME")
def rdsDbName = System.getProperty("RDS_DB_NAME")
def rdsUsername = System.getProperty("RDS_USERNAME")
def rdsPassword = System.getProperty("RDS_PASSWORD")
def rdsPoolProps = JSON.parse(System.getProperty("RDS_POOL_PROPS"))
// environment specific settings
environments {
// ......
production {
dataSource {
pooled = true
url = "jdbc:mysql://${rdsHostname}:3306/${rdsDbName}"
driverClassName = "com.mysql.jdbc.Driver"
username = rdsUsername
password = rdsPassword
properties {
jmxEnabled = true
initialSize = rdsPoolProps.initialSize
maxActive = rdsPoolProps.maxActive
minIdle = rdsPoolProps.minIdle
maxIdle = rdsPoolProps.maxIdle
maxWait = 10000
maxAge = 7 * 60000
// ..................
请注意数据源rdsPoolProps
关闭时properties
的使用情况。
当我建立战争时,我收到了这个错误:
| Error Error packaging application: Error loading DataSource.groovy: No signature of method: groovy.util.ConfigObject.parse() is applicable for argument types: (null) values: [null]
Possible solutions: values(), merge(groovy.util.ConfigObject), take(int), plus(java.util.Collection), use([Ljava.lang.Object;), plus(java.util.Map) (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
org.codehaus.groovy.grails.compiler.PackagingException: Error loading DataSource.groovy: No signature of method: groovy.util.ConfigObject.parse() is applicable for argument types: (null) values: [null]
Possible solutions: values(), merge(groovy.util.ConfigObject), take(int), plus(java.util.Collection), use([Ljava.lang.Object;), plus(java.util.Map)
at _GrailsPackage$_run_closure2.doCall(_GrailsPackage.groovy:48)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.codehaus.gant.GantMetaClass.processClosure(GantMetaClass.java:81)
at org.codehaus.gant.GantMetaClass.processArgument(GantMetaClass.java:95)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:128)
at _GrailsWar$_run_closure2.doCall(_GrailsWar.groovy:41)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.codehaus.gant.GantMetaClass.processClosure(GantMetaClass.java:81)
at org.codehaus.gant.GantMetaClass.processArgument(GantMetaClass.java:95)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:128)
at War$_run_closure1.doCall(War.groovy:38)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:591)
at gant.Gant.executeTargets(Gant.groovy:590)
Caused by: groovy.lang.MissingMethodException: No signature of method: groovy.util.ConfigObject.parse() is applicable for argument types: (null) values: [null]
Possible solutions: values(), merge(groovy.util.ConfigObject), take(int), plus(java.util.Collection), use([Ljava.lang.Object;), plus(java.util.Map)
at DataSource.run(DataSource.groovy:13)
... 41 more
有一个简单的解决方法吗?我想做一些负载测试,而不必在每次调整时打包和重新部署。