#29 pass: spring batch simple example
This commit is contained in:
@@ -1,11 +1,43 @@
|
||||
package com.example.passbatch;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
|
||||
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
|
||||
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
|
||||
import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
import org.springframework.batch.core.step.tasklet.Tasklet;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@EnableBatchProcessing
|
||||
@SpringBootApplication
|
||||
@RequiredArgsConstructor
|
||||
public class PassBatchApplication {
|
||||
|
||||
private final JobBuilderFactory jobBuilderFactory;
|
||||
private final StepBuilderFactory stepBuilderFactory;
|
||||
|
||||
@Bean
|
||||
public Step passStep() {
|
||||
return this.stepBuilderFactory.get("passStep")
|
||||
.tasklet((contribution, chunkContext) -> {
|
||||
System.out.println("Execute PassStep");
|
||||
return RepeatStatus.FINISHED;
|
||||
}).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Job passJob() {
|
||||
return this.jobBuilderFactory.get("passJob")
|
||||
.start(passStep())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PassBatchApplication.class, args);
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
6
pass-batch/src/main/resources/application.yml
Normal file
6
pass-batch/src/main/resources/application.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:h2:mem:mydb
|
||||
username: pass_local
|
||||
password: 1234
|
||||
driver-class-name: org.h2.Driver
|
||||
Reference in New Issue
Block a user