spring-batch - Spring批处理条件流配置错误
问题描述
我有一个 XML 配置的步骤,我想添加batch:next
元素以便在我的工作中获得条件流动:
<batch:step id="stepLoadCashFlows">
<batch:next on="*" to="stepCleanOldTrades" />
<batch:next on="FAILED" to="stepCleanCurrentTradesOnError" />
<batch:tasklet>
<batch:chunk reader="cashFlowItemReader" writer="cashFlowItemWriter"
processor="cashFlowsProcessor" commit-interval="10000" skip-limit="${cds.skip.limit}">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.integration.transformer.MessageTransformationException" />
</batch:skippable-exception-classes>
</batch:chunk>
</batch:tasklet>
<listeners>
<listener ref="cashFlowWriterListener" />
</listeners>
</batch:step>
这让我得到以下错误:
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:cpm-batch-main-cds-load.xml]
Offending resource: class path resource [cpm-dml-subscriber-cds-top-level.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 80 in XML document from class path resource [cpm-batch-main-cds-load.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 80; columnNumber: 19; cvc-complex-type.2.4.a : Invalid content found starting with element 'batch:tasklet'. One of the following values '{"http://www.springframework.org/schema/batch":next, "http://www.springframework.org/schema/batch":stop, "http://www.springframework.org/schema/batch":end, "http://www.springframework.org/schema/batch":fail, "http://www.springframework.org/schema/batch":listeners}' is expected.
那么我应该把这些放在哪里(我在步骤结束时尝试过,在tasklet中......)?
解决方案
过渡元素应该放在tasklet
元素之后。因此,在您的情况下,以下应该有效:
<batch:step id="stepLoadCashFlows">
<batch:tasklet>
<batch:chunk reader="cashFlowItemReader" writer="cashFlowItemWriter"
processor="cashFlowsProcessor" commit-interval="10000" skip-limit="${cds.skip.limit}">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.integration.transformer.MessageTransformationException" />
</batch:skippable-exception-classes>
</batch:chunk>
<batch:listeners>
<batch:listener ref="cashFlowWriterListener" />
</batch:listeners>
</batch:tasklet>
<batch:next on="*" to="stepCleanOldTrades" />
<batch:next on="FAILED" to="stepCleanCurrentTradesOnError" />
</batch:step>
请注意,listeners
元素应该在tasklet
元素内部。
推荐阅读
- swing - 侦听器中无法识别的变量 - Jython Swing
- reactjs - React 中 setState() 之后的代码会运行吗?
- sql - SQL表返回函数中的SQL ORDER BY
- angular - 更新 promise ionic 4 中的数组值
- ios - 当我保持手腕向下时,如何在 iWatch 应用中继续播放音频?- 手表操作系统
- android - 如何在预构建阶段在 Gradle 中下载和实现依赖项?
- ios - 重命名视图控制器后xcode iOS App崩溃
- android - 无法将分支键用作清单占位符
- jquery - 单击(链接)HREF 时,滚动到 Angular JS 中的页面顶部
- testing - ActiveMQ Artemis 读取消息而不在 JMeter 中使用它