xml - Xml Spring批处理作业像if else一样执行
问题描述
我做了春季批量工作,但我卡在了某个地方。我正在尝试在春季批处理 XML 作业中从用户那里获取参数,基于该参数我将运行不同的步骤。
例如。Argument= new 或 replace 基于 "Argument" ,将执行不同的步骤 If argument=new then step 1 Else If argument=replace then step 2 Else some error
非常感谢您的任何领导或帮助。
解决方案
您可以根据系统属性创建决策程序来决定使用哪个步骤,例如:
class MyDecider implements JobExecutionDecider {
@Override
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
String operation = System.getProperty("operation");
if (operation.equalsIgnoreCase("create"))
return new FlowExecutionStatus("create");
else {
return new FlowExecutionStatus("update");
}
}
}
然后在你的工作定义中使用这个决定器:
<beans:bean id="decider" class="MyDecider"/>
<job id="job">
<step id="step1" next="decision" />
<decision id="decision" decider="decider">
<next on="create" to="createStep" />
<next on="update" to="updateStep" />
</decision>
<step id="createStep"/>
<step id="updateStep"/>
</job>
推荐阅读
- javascript - 如何使用reactjs和material ui将文本字段添加到表格内的特定行单击按钮
- python - python 基于单个列表的列表字典排序
- javascript - 多选仅在发送到firebase时给出第一个选择
- javascript - 使用 Google App Script 修改 Google Sheet 中的单元格
- json - 如何使用 POST 方法在颤振中获得 json 响应?
- c# - Blazor 布局 = null
- java - IntelliJ 运行/调试配置日志记录
- java - 计算不同的字符而不转换为小写
- c# - 如何显示包含大量数据的 sqlcommand 查询的结果?
- influxdb - 为什么这个 InfluxDB Flux 查询返回 2 个表?