Java 在决策器中访问spring批处理作业参数
我有一个spring批处理作业,我把一个文件名作为作业参数,我需要在决策器中使用这个参数,我该怎么做呢 我的决定者:Java 在决策器中访问spring批处理作业参数,java,spring,spring-batch,Java,Spring,Spring Batch,我有一个spring批处理作业,我把一个文件名作为作业参数,我需要在决策器中使用这个参数,我该怎么做呢 我的决定者: 公共类MyDecider实现JobExecutionDecider { public FlowExecutionStatus Decision(作业执行、作业执行、, org.springframework.batch.core.StepExecution(步骤执行) { 字符串文件名=jobExecution.getExecutionContext().getStri
公共类MyDecider实现JobExecutionDecider
{
public FlowExecutionStatus Decision(作业执行、作业执行、,
org.springframework.batch.core.StepExecution(步骤执行)
{
字符串文件名=jobExecution.getExecutionContext().getString(“文件”);
System.out.println(“步骤执行中的filae名称:“+fileName”);
FileRead FileRead=新建FileRead();
if(fileName.equals(“aaaa”))
{
返回FlowExecutionStatus.COMPLETED;
}
其他的
{
返回FlowExecutionStatus.FAILED;
}
}
}
JobExecutionDecider#decise方法采用类型为JobExecution
的参数,允许您使用JobExecution.getJobParameters
获取作业参数。下面是一个简单的例子:
class MyDecider implements JobExecutionDecider {
@Override
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
JobParameters jobParameters = jobExecution.getJobParameters();
// get the job parameter from jobParameters
return null; // return the FlowExecutionStatus as needed
}
}
JobExecutionDecider#decise
方法采用类型为JobExecution
的参数,允许您使用JobExecution.getJobParameters
获取作业参数。下面是一个简单的例子:
class MyDecider implements JobExecutionDecider {
@Override
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
JobParameters jobParameters = jobExecution.getJobParameters();
// get the job parameter from jobParameters
return null; // return the FlowExecutionStatus as needed
}
}
什么是决策者?我加上了决策者。它是根据某件事对工作做出决定。什么是决策者?我加上了决策者。它是根据某件事在工作中做出决定。