gpt4 book ai didi

spring - ConversionNotSupportedException : Failed to convert property value of type 'grails.spring.BeanBuilder' to required type 'java.lang.String'

转载 作者:行者123 更新时间:2023-12-02 15:29:51 26 4
gpt4 key购买 nike

我正在处理这个 grails-aws插件并尝试在 Grails 2.3.4 和 2.3.5 下运行时出现奇怪的错误。

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

最佳答案

这在 this Grails JIRA 中有解释。 - 显然 BeanBuilder 使用“委托(delegate)优先”行为调用其闭包,但之前在 Groovy 中存在一个错误,这意味着调用匹配 static包含范围的方法忽略了解析策略设置并调用了静态方法。换句话说,您以前使用的代码只是偶然发生的。如果你用类名 AwsPluginSupport.read(...) 限定静态方法,你应该仍然可以调用它。 .

或者,您可以完全跳过体操 - 使用文字 '${....}' bean 属性的表达式并让 property placeholder mechanism为您从配置中提取值。 IE。代替

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(在解析时将 [fail to] 由 Groovy 解析)。

关于spring - ConversionNotSupportedException : Failed to convert property value of type 'grails.spring.BeanBuilder' to required type 'java.lang.String' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21388387/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com