简体   繁体   English

是否可以将 JobParameter 放在 Tasklet 步骤中? (春季批次)

[英]Is it possible to put JobParameter in Tasklet step? (Spring Batch)

I need to avoid process same file twice in Spring Batch project.我需要避免在 Spring Batch 项目中两次处理相同的文件。 Therefore I need to put file name as a Job Parameter.因此我需要将文件名作为作业参数。 However, I know file name only in step1, not before the job execution.但是,我只在步骤 1 中知道文件名,而不是在作业执行之前。 Therefore I can't pass file name as a job parameter while launching a job.因此,我不能在启动作业时将文件名作为作业参数传递。 My question is that, is there any other way to pass job parameter in step1 after get to know file name?我的问题是,在知道文件名后,有没有其他方法可以在 step1 中传递作业参数?

You don't need to add a parameter to Spring Batch, you need to pass data between steps.您不需要在 Spring Batch 中添加参数,您需要在步骤之间传递数据。 Here are some ways to do that => Storing in JobExecutionContext from tasklet and accessing in another tasklet这里有一些方法可以做到这一点 => 从 tasklet 存储在 JobExecutionContext 中并在另一个 tasklet 中访问

Hope it helps !希望能帮助到你 !

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM