spring-batch JobScheduler 源码
spring-batch JobScheduler 代码
文件路径:/spring-batch-samples/src/main/java/org/springframework/batch/sample/metrics/JobScheduler.java
package org.springframework.batch.sample.metrics;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class JobScheduler {
private final Job job1;
private final Job job2;
private final JobLauncher jobLauncher;
@Autowired
public JobScheduler(Job job1, Job job2, JobLauncher jobLauncher) {
this.job1 = job1;
this.job2 = job2;
this.jobLauncher = jobLauncher;
}
@Scheduled(cron = "*/10 * * * * *")
public void launchJob1() throws Exception {
JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis())
.toJobParameters();
jobLauncher.run(job1, jobParameters);
}
@Scheduled(cron = "*/15 * * * * *")
public void launchJob2() throws Exception {
JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis())
.toJobParameters();
jobLauncher.run(job2, jobParameters);
}
}
相关信息
相关文章
spring-batch BatchMetricsApplication 源码
spring-batch Job1Configuration 源码
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦