Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- formik
- LPOS
- pinpoint 2.5.3
- RedirectService
- 애자일 싫타
- nGinder
- 논블록킹 성능
- reids
- ㅉ때
- jar 배포
- pinpoint
- 플루터
- 개발 어렵당.ㅠ
- UnsupportedOperationException
- fake jwt
- hbase 저장공간 설정
- 핀포인트
- 오블완
- 노드간 통신
- 7879
- OIDC
- 월급루팡 일지
- jsonMarshaller
- intellij
- R2DBC Paging
- Loki 로그
- Ingress Controller Fake
- save/update
- 티스토리챌린지
- Armeria
Archives
- Today
- Total
대머리개발자
[코틀린] 스프링 배치(2) - 적용 본문
728x90
가즈아!!!
1. 코틀린에서 JPA를 사용하기 위한 추가 작업
allOpen { // 추가적으로 열어줄 allOpen
annotation("jakarta.persistence.Entity")
annotation("jakarta.persistence.MappedSuperclass")
annotation("jakarta.persistence.Embeddable")
}
2. EnableBatchProcessing 추가
@SpringBootApplication
@EnableBatchProcessing
class Batch02Application
3. 역시는 역시다. 그냥 되는 게 없다. ㅋㅋ 디플리케이트...ㄸ1발
다시 2번으로 돌아가서 -> @EnableBatchProcessing 제거한다. 필요 없단다..
3. 구글형님...
package com.batch02.test
import org.springframework.batch.core.Job
import org.springframework.batch.core.Step
import org.springframework.batch.core.StepContribution
import org.springframework.batch.core.job.builder.JobBuilder
import org.springframework.batch.core.repository.JobRepository
import org.springframework.batch.core.scope.context.ChunkContext
import org.springframework.batch.core.step.builder.StepBuilder
import org.springframework.batch.core.step.tasklet.Tasklet
import org.springframework.batch.repeat.RepeatStatus
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.transaction.PlatformTransactionManager
@Configuration
class BatchJobConfiguration{
@Bean
fun testTasklet(): Tasklet {
return Tasklet { contribution: StepContribution?, chunkContext: ChunkContext? ->
// 태스크 내용 todo
RepeatStatus.FINISHED
}
}
@Bean
fun myStep(
jobRepository : JobRepository
, testTasklet : Tasklet
, transactionManager: PlatformTransactionManager?
): Step {
return StepBuilder("myStep", jobRepository)
.tasklet(testTasklet, transactionManager!!) // or .chunk(chunkSize, transactionManager)
.build()
}
@Bean
fun myJob(jobRepository : JobRepository, step :Step): Job {
return JobBuilder("myJob", jobRepository)
.start(step)
.build()
}
}
DB가 없어서... 오류 뿜뿜..
spring:
batch:
job:
enabled: true
jdbc:
initialize-schema: always
일회성 한번 만들고.. 주석처리하거나 naver 처리한다.
좀 더 디테일한 내용은 차차 알아보자..
728x90
'개발이야기 > 코틀린' 카테고리의 다른 글
코틀린 Jpa 영속성... (0) | 2023.10.23 |
---|---|
[코틀린] 더욱 코틀린스럽게(apply, also) (0) | 2023.09.07 |
[코틀린] 스프링 배치(1) - 사전 주저리 (0) | 2023.09.01 |
[코틀린] queryDSL (1) | 2023.06.13 |
[코틀린] NULL 처리 (0) | 2023.05.16 |