You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring5升级后Spring Integration配置报错:int:filter属性及子元素异常

Spring 5升级中Spring Integration配置错误修复

原配置代码

<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="onFailureExpressionString" value="payload" />
            <property name="failureChannel" ref="eventSpringXpathErrorChannel" />
            <property name="trapException" value="true" />
        </bean>
    </int:request-handler-advice-chain>
</int:filter>

错误信息(翻译后)

  1. cvc-complex-type.3.2.2: 元素'int:filter'中不允许出现属性'expression'
  2. 无效元素名称:
  • request-handler-advice-chain
    预期为以下元素之一:
  • bean
  • poller

修复方案

针对错误1调整表达式配置

Spring Integration 5.x中,<int:filter>不再支持直接配置expression属性,需要将过滤表达式移至<int:expression>子元素中定义。

针对错误2调整增强链配置

<int:request-handler-advice-chain>已不是<int:filter>的合法子元素,需替换为<int:advice-chain>来配置处理器增强逻辑。

修复后完整配置

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

补充说明

确保配置文件头部的Spring Integration命名空间引用已升级至Spring 5对应的版本:

xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/integration
    https://www.springframework.org/schema/integration/spring-integration.xsd"

内容的提问来源于stack exchange,提问作者VKR

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 01:01:20