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

XSD变更致fixed-delay失效,如何配置Spring Integration Poller?

Spring Integration Poller 配置修复方案

问题概述

原Poller配置因XSD版本变更,fixed-delay属性不再被允许,Eclipse中XML解析报错:

<int:poller default="true" task-executor="stepTaskExecutor" fixed-delay="1000">

尝试用嵌套<int:interval-trigger>的方式替换后,IDE解析通过但运行时触发XML Schema校验错误:

<int:poller default="true" task-executor="stepTaskExecutor">
    <int:interval-trigger interval="1000"/>
</int:poller>

报错核心信息:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'int:interval-trigger'. One of '{"http://www.springframework.org/schema/integration":transactional, "http://www.springframework.org/schema/integration":advice-chain}' is expected.

正确配置方式

根据Spring Integration的XSD约束,<int:poller>的子元素仅支持<int:transactional>或<int:advice-chain>,触发逻辑需要通过引用外部Trigger Bean来实现,而非嵌套触发元素。

方案1:显式定义IntervalTrigger Bean并引用

<!-- 定义固定延迟触发Bean -->
<bean id="defaultPollerTrigger" class="org.springframework.integration.util.IntervalTrigger">
    <constructor-arg value="1000"/> <!-- 延迟间隔,单位毫秒 -->
</bean>

<!-- 全局默认Poller配置 -->
<int:poller default="true" task-executor="stepTaskExecutor" trigger="defaultPollerTrigger"/>

方案2:使用XSD支持的属性配置(版本依赖)

如果你的Spring Integration版本(如5.0+)对应的XSD仍允许,也可以直接使用fixed-delay作为属性,但需确保XML头部的schema声明与依赖版本匹配:

<int:poller default="true" task-executor="stepTaskExecutor" fixed-delay="1000"/>

注:若此方式仍报错,说明当前XSD版本已移除该属性,请优先使用方案1。

额外注意事项

确保XML配置头部的Spring Integration命名空间和schema地址与项目依赖的版本一致,避免版本不匹配导致的校验错误:

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,提问作者pojo-guy

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 02:35:22