【问题标题】:pass -next option to spring JobLauncher将 -next 选项传递给 spring JobLauncher
【发布时间】:2013-08-13 23:18:20
【问题描述】:

我正在使用 org.springframework.batch.core.launch.JobLauncher 以编程方式执行批处理作业

在我的代码中,我有这样的声明

JobExecution result = jobLauncher.run(job, parameters);

我使用参数运行的大多数批处理作业,但我的批处理作业之一不使用任何参数。所以,我已经用org.springframework.batch.core.launch.support.RunIdIncrementer 设置了那个工作

为了用户增量,我必须为 JobLauncher 提供 -next 选项。如何传递我的 jobLauncher 这个 -next 参数?

【问题讨论】:

    标签: spring spring-batch


    【解决方案1】:

    我有同样的问题,我没有找到任何解决方案如何在代码中添加“下一个”参数。取而代之的是,您可以将当前时间作为参数:

    Map<String, JobParameter> jobParameterMap = new HashMap<String, JobParameter>();
    jobParameterMap.put("date", new JobParameter(new Date()));
    JobExecution exec = jobLauncher.run(job, new JobParameters(jobParameterMap));
    

    【讨论】:

      【解决方案2】:

      JobLauncher 上没有等效项来增加 JobParameters。以这种方式启动作业的方法是使用JobOperator#startNextInstance(String jobName)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-12-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-21
        • 2017-08-13
        相关资源
        最近更新 更多