Spring Batch 5

<aside> ๐Ÿ’ก Spring Batch 5๋Š” ์ตœ์†Œ ๋ฒ„์ „์œผ๋กœ Java 17์ด ํ•„์š”ํ•œ Spring Framework 6์„ ๊ธฐ๋ฐ˜ https://github.com/spring-projects/spring-batch/wiki/Spring-Batch-5.0-Migration-Guide#dependencies-upgrade

</aside>

1. build.gradle


dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-batch'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation'org.springframework.boot:spring-boot-starter-quartz'
    implementation 'org.postgresql:postgresql:42.7.2'

    runtimeOnly 'org.postgresql:postgresql'

    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'

    testImplementation platform('org.junit:junit-bom:5.9.1')
    testImplementation 'org.junit.jupiter:junit-jupiter'
}

2. application.yml

spring:
  main:
    allow-bean-definition-overriding: true
  batch:
    job:
      enabled: true # ์„œ๋ฒ„ ์žฌ์‹œ์ž‘์‹œ ๋ฐฐ์น˜ ์ž๋™์‹คํ–‰ ๋ฐฉ์ง€ = false
      jdbc:
        initialize-schema: always 
  quartz:
    job-store-type: jdbc
    jdbc:
      initialize-schema: always 
 # DB ...

3. Main

//@EnableBatchProcessing  //  ๋ฐฐ์น˜ ๊ธฐ๋Šฅ ํ™œ์„ฑ spring 3.0 ์ด์ƒ์€ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค ๊ธฐ๋ณธ ์„ค์ •์ด ๋ฐฑ์˜คํ”„ ๋œ๋‹ค.
@EnableScheduling  //Spring scheduler
@SpringBootApplication
public class BatchTestApplication {
    public static void main(String[] args) {
        SpringApplication.run(BatchTestApplication.class, args);
    }
}

4. Job.java

Untitled

Job - ์ฒ˜๋ฆฌํ•˜๊ณ ์ž ํ•˜๋Š” ์ž‘์—… ๋‹จ์œ„