spring batch : scheduling

This commit is contained in:
haerong22
2021-05-13 16:29:38 +09:00
parent 40d23d51b9
commit 85f35be99b
4 changed files with 29 additions and 10256 deletions

View File

@@ -3,9 +3,11 @@ package com.example.springbatch;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableBatchProcessing
@EnableScheduling
public class SpringBatchApplication {
public static void main(String[] args) {

View File

@@ -0,0 +1,25 @@
package com.example.springbatch.application.scheduler;
import lombok.RequiredArgsConstructor;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import java.util.Date;
@Configuration
@RequiredArgsConstructor
public class JobScheduler {
private final Job createArticleJob;
private final JobLauncher jobLauncher;
@Scheduled(fixedDelay = 5000)
public void runCreateArticleJob() throws Exception{
jobLauncher.run(createArticleJob, new JobParametersBuilder()
.addDate("date", new Date())
.toJobParameters());
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@ spring:
batch:
initialize-schema: always
job:
names: ${job.name:createArticleJob}
names: ${job.name:NONE}
# # 데이터베이스 분리 방법 (1)
# schema: schema-mysql.sql
# table-prefix: batch.BATCH_