将类型为“java.lang.String”的属性值转换为属性“onFailureExpression”所需的类型“org.springframework.expression.Expression "

pn9klfpd  于 2022-11-21  发布在  Spring
关注(0)|答案(1)|浏览(130)

我遇到了以下错误,使用的是Spring版本5.3.14和Spring_integration 5.5.7,使用的是camel版本2.25.4。

org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.expression.Expression' for property 'onFailureExpression'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'org.springframework.expression.Expression' for property 'onFailureExpression': no matching editors or conversion strategy found

配置文件:

<int:filter id="xpathfilter" input-channel="eventSpringXpathChannel"
        output-channel="eventSpringOutChannel" discard-channel="eventSpringFailureChannel"
        expression="#xpath(payload, headers.get('xpathKey'), 'boolean')">
        <int:request-handler-advice-chain>
<bean           class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
    <property name="onFailureExpression" value="payload" />
    <property name="failureChannel" ref="eventSpringXpathErrorChannel" />
    <property name="trapException" value="true" />
</bean>
        </int:request-handler-advice-chain>
    </int:filter>
xiozqbni

xiozqbni1#

该setter需要org.springframework.expression.Expression的示例,但您只提供了value="payload",而它实际上不是Expression
另见二传手:

/**
 * Set the expression to evaluate against the root message after a failed
 * handler invocation. The exception is available as the variable {@code #exception}.
 * Defaults to {@code payload}, if {@code failureChannel} is configured.
 * @param onFailureExpression the SpEL expression.
 * @since 4.3.7
 */
public void setOnFailureExpressionString(String onFailureExpression) {

因此,您的配置如下所示:

<property name="onFailureExpressionString" value="payload" />

相关问题