gpt4 book ai didi

java - 在评估 spring 集成表达式时获取类转换表达式

转载 作者:行者123 更新时间:2023-12-01 09:53:38 26 4
gpt4 key购买 nike

我在使用 Spring Integration 编译下面的表达式时遇到类转换异常。

异常:

Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.Class to type java.lang.String

表达式:

<int:transformer expression=
"((#{T(my.package.exceptions.MyCustomException)})
payload.getCause()).getMyCustomStringAssociatedWithExceptionInstance()" />

有什么帮助吗?

最佳答案

您无法使用 SpEL 进行转换(它不是 Java);但你不需要 - 你可以简单地使用

expression="payload.cause.myCustomStringAssociatedWithExceptionInstance"

魔法!

您也可以使用显式 getter,但 SpEL 会隐式使用它们。

关于java - 在评估 spring 集成表达式时获取类转换表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37413329/

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