2014-01-27 59 views
0

我正在研究这个grails-aws插件,并尝试在Grails 2.3.4下运行时出现奇怪的错误和2.3.5。ConversionNotSupportedException:未能将类型'grails.spring.BeanBuilder'的属性值转换为所需的类型'java.lang.String'

travis build output其中测试通过Grails的2.0.4/2.2.4,但失败2.3.4/2.3.5

有事与Grails的2.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]:找不到匹配的编辑器或转换策略(注意:堆栈跟踪具有被过滤使用--verbose看到整个跟踪)

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 

回答

1

这在this Grails JIRA解释 - 。显然BeanBuilder调用它的倒闭与“代表第一”的行为,但以前有在Groovy中的错误这意味着电话与包含作用域的static方法相匹配的方法忽略了解决策略设置并无论如何都调用静态方法。换句话说,你以前使用的代码只是偶然的工作。如果您使用类名称AwsPluginSupport.read(...)来限定它,您仍然应该能够调用静态方法。

或者,您可以完全跳过体操 - 为文字属性使用文字'${....}'表达式,并让property placeholder mechanism将值从您的配置中拉出。即而不是

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}' 
} 

注意,这一点很重要,这些都是单引号字符串(所以价值包括${}弹簧能解析表达式),而不是双引号 GString的(这会在分析时由Groovy解决)。

相关问题