【问题标题】:Convert property value of type 'java.lang.String' to required type 'org.springframework.expression.Expression' for property 'onFailureExpression'将类型 \'java.lang.String\' 的属性值转换为属性 \'onFailureExpression\' 所需的类型 \'org.springframework.expression.Expression\'
【发布时间】:2022-11-16 04:12:24
【问题描述】:

我面临以下错误并使用 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>

【问题讨论】:

    标签: spring spring-integration


    【解决方案1】:

    该 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" />
    

    【讨论】:

    • 当提供 failureChannel 时,payload 也是默认表达式。
    猜你喜欢
    • 2021-06-13
    • 2017-05-06
    • 2015-03-29
    • 2013-10-26
    • 2021-06-26
    • 2019-07-11
    • 1970-01-01
    • 1970-01-01
    • 2017-05-12
    相关资源
    最近更新 更多