Skip to content

Instantly share code, notes, and snippets.

@yamabicodev
Last active February 25, 2021 08:13
Show Gist options
  • Save yamabicodev/89d71d876af4d73778f637d622b720f7 to your computer and use it in GitHub Desktop.
Save yamabicodev/89d71d876af4d73778f637d622b720f7 to your computer and use it in GitHub Desktop.
springbatch-DemoBatchConfigure.java
@Configuration
@EnableBatchProcessing
@AllArgsConstructor
public class DemoBatchConfigure {
//:省略
@Bean
public MyBatisCursorItemReader<Article> reader() {
return new MyBatisCursorItemReaderBuilder<Article>()
.sqlSessionFactory(sqlSessionFactory)
.queryId(ArticleMapper.class.getName() + ".findAll")
.build();
}
// :Writeの設定部分は省略
// chunk(3)とし、3件単位でwriteの処理を行うように指定
@Bean
public Step step(ItemReader<Article> reader, ItemWriter<ArticleSummary> writer) {
return steps.get("step")
.<Article, ArticleSummary>chunk(3)
.reader(reader)
.processor(processor)
.writer(writer)
.build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment