Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
spring批处理永远只运行一次任务_Spring_Spring Batch - Fatal编程技术网

spring批处理永远只运行一次任务

spring批处理永远只运行一次任务,spring,spring-batch,Spring,Spring Batch,我有一份春季批量工作。作业中的第一个任务是创建虚拟数据。我只想运行此作业一次,不管在此之后作业运行了多少次,或者可以根据属性文件中的某些属性值将此任务配置为仅运行一次。如何实现此功能 在生产系统中,这可能与在处理文件之前创建文件夹结构以复制不同的文件类型相同 Spring Batch的界面就是您要寻找的。您必须实现execute方法 public class FolderTasklet implements Tasklet{ public RepeatStatus execute(St

我有一份春季批量工作。作业中的第一个任务是创建虚拟数据。我只想运行此作业一次,不管在此之后作业运行了多少次,或者可以根据属性文件中的某些属性值将此任务配置为仅运行一次。如何实现此功能

在生产系统中,这可能与在处理文件之前创建文件夹结构以复制不同的文件类型相同

Spring Batch的界面就是您要寻找的。您必须实现
execute
方法

public class FolderTasklet implements Tasklet{

    public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
    //your copy folder structure logic goes here
    }
}

我现在正在使用一个tasklet,根据官方文档,看起来它应该用于设置资源和清理。我一直在寻找的是,无论一个作业运行多少次,只做一次。我想这类事情需要在工作之外完成,然后再运行工作。感谢您的响应。批处理作业主要适用于读写器场景。如果在每次作业执行的主要步骤之前需要设置,可以将其创建为父步骤。但是,如果您只需要此设置过程一次,最好使用tasklet创建另一个作业。