[Spring Batch] 프로젝트 생성

2024. 9. 16. 23:02프로그래밍(Backend)/Spring Batch

https://start.spring.io/

Spring Initializr 를 통한 스프링 부트 프로젝트 생성

프로젝트 의존성

  • Lombok
  • Spring Web
  • JDBC API
  • Spring Data JPA
  • MySQL Driver
  • Spring Batch

Gradle

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-batch'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'com.mysql:mysql-connector-j'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.springframework.batch:spring-batch-test'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

 

패키지 생성 : 앞으로 여러 클래스 작성을 위해

  • batch
  • config
  • controller
  • entity
  • repository
  • schedule

패키지 생성

2개의 데이터 베이스 연결

1. meta_db

  • 배치 작업의 진행 사항 및 내용에 대한 메타데이터를 기록하는 테이블을 위한 DB

2. data_db

  • 배치 작업 데이터용 DB

데이터베이스 연결 변수 application.yml

datasource-meta:
  driver-class-name: org.mariadb.jdbc.Driver
  jdbc-url: jdbc:mariadb://localhost:3306/meta_db?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul&allowPublicKeyRetrieval=true
  username: user
  password: user

datasource-data:
  driver-class-name: org.mariadb.jdbc.Driver
  jdbc-url: jdbc:mariadb://localhost:3306/data_db?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul&allowPublicKeyRetrieval=true
  username: user
  password: user