我正在开发这个grails-aws插件,在Grails2.3.4和2.3.5下运行时会出现一个奇怪的错误。
参见travis构建输出,Grails2.0.4/ 2.2.4测试通过,2.3.4 / 2.3.5测试失败
在从配置文件读取值的区域中,grails2.3.x是否发生了一些变化?
创建名为“credentialsHolder”的bean时出错:初始化bean失败;嵌套异常为org.springframework.beans.ConversionNotSupportedException:未能将属性' grails.spring.BeanBuilder‘的属性值转换为属性’accessKey‘的必需类型' java.lang.String’;嵌套异常为java.lang.IllegalStateException:无法将grails.spring.BeanBuilder类型的值转换为属性“accessKey”的必需类型java.lang.String:未找到匹配的编辑器或转换策略(注意:已筛选堆栈跟踪)。使用--详细地查看整个跟踪。)
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'credentialsHolder': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'grails.spring.BeanBuilder' to required type 'java.lang.String' for property 'accessKey'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [grails.spring.BeanBuilder] to required type [java.lang.String] for property 'accessKey': no matching editors or conversion strategy found发布于 2014-01-30 17:23:07
这在这个Grails JIRA中得到了解释--显然,BeanBuilder使用“委托优先”的行为调用它的闭包,但是以前在Groovy中有一个bug,它意味着与包含作用域的static方法匹配的调用忽略了解决策略设置,并且无论如何都调用了静态方法。换句话说,您以前使用过的代码只是偶然使用过的。如果将静态方法限定为类名AwsPluginSupport.read(...),则仍然可以调用它。
或者,您可以跳过整个过程--为bean属性使用文字'${....}'表达式,并让属性占位符机制为您从配置中提取值。即代替
credentialsHolder(AWSCredentialsHolder) {
accessKey = readString("credentials.accessKey")
secretKey = readString("credentials.secretKey")
properties = readString("credentials.properties")
}使用
credentialsHolder(AWSCredentialsHolder) {
accessKey = '${grails.plugin.aws.credentials.accessKey}'
secretKey = '${grails.plugin.aws.credentials.secretKey}'
properties = '${grails.plugin.aws.credentials.properties}'
}请注意,这些字符串是单引号字符串(因此值是一个表达式,包括${},Spring可以解析),而不是双引号的GStrings (解析时不能由Groovy解析)。
发布于 2014-01-31 03:37:14
拉请求作为解决此问题的方法提交。
https://stackoverflow.com/questions/21388387
复制相似问题