사용자 도구

사이트 도구


springframework:batch

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
springframework:batch [2018/11/21 17:33]
kwon37xi [RunIdIncrementer 사용시 기존 파라미터가 현재 파라미터 지정한 것을 덮어씀]
springframework:batch [2019/06/19 10:05]
kwon37xi
줄 32: 줄 32:
   * [[https://www.mkyong.com/spring-batch/spring-batch-example-mysql-database-to-xml/|Spring Batch Example – MySQL Database To XML – Mkyong.com]]   * [[https://www.mkyong.com/spring-batch/spring-batch-example-mysql-database-to-xml/|Spring Batch Example – MySQL Database To XML – Mkyong.com]]
   * [[https://examples.javacodegeeks.com/enterprise-java/spring/batch/spring-batch-exception-handling-example/|Spring Batch Exception Handling Example | Examples Java Code Geeks - 2018]]   * [[https://examples.javacodegeeks.com/enterprise-java/spring/batch/spring-batch-exception-handling-example/|Spring Batch Exception Handling Example | Examples Java Code Geeks - 2018]]
 +  * [[http://www.egovframe.go.kr/wiki/doku.php?id=egovframework:rte2:brte:batch_core:parallel_process|egovframework:rte2:brte:batch_core:parallel_process [eGovFrame]]]
 +
 +
 ===== @EnableBatchProcessing ===== ===== @EnableBatchProcessing =====
   * [[https://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.html|@EnableBatchProcessing]]을 통해 기본 배치 설정을 수행한다.   * [[https://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.html|@EnableBatchProcessing]]을 통해 기본 배치 설정을 수행한다.
줄 144: 줄 147:
 } }
 </code> </code>
 +
 +===== Java Config Spring Bean 설정시 리턴 타입을 인터페이스가 아닌 구현 클래스로 지정할 것. =====
 +  * ''@StepScope'' 등을 사용하는 등 할 경우 리턴 타입을 ''ItemReader<X>'', ''ItemWriter<Y>'' 처럼 인터페이스로 할 경우 프록시 객체가 생성되고 그로 인해서 ''instanceOf'' 를 사용하는 일부 코드들이 작동하지 않거나, annotation 기반의 listener 등이 동작하지 않는 문제를 일으킨다.
 +  * 따라서 Spring Batch 용 각 스텝별 Bean 을 생성해서 리턴할 때는 항상 **구현 클래스를 리턴 타입으로 지정**할 것.
 +  * [[https://jojoldu.tistory.com/132|[batch] @StepScope 사용시 주의사항]]
 +  * 다음과 같은 WARN 을 볼 수도 있다.
 +
 +> o.s.b.c.l.AbstractListenerFactoryBean    : org.springframework.batch.item.ItemReader is an interface.  The implementing class will not be queried for annotation based listener configurations.  If using @StepScope on a @Bean method, be sure to return the implementing class so listner annotations can be used.
 +
 +
 +===== Test =====
 +  * [[https://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/test/JobLauncherTestUtils.html|JobLauncherTestUtils]]로 테스트 가능. 
 +    * 이 클래스는 static utility 가 아니라 Bean 으로 생성해줘야 하는 것이다.
 +    * ''setJob()''으로 특정 Job을 지정하거나, 그냥 ''@Autowired''될 수도 있음.
 +    * 특정 Step만 테스트도 가능함.
 +  * [[springframework:springboot:batch|SpringBoot와 SpringBatch]] 시에는 ''@MockBean''도 가능.
 +  * [[https://www.mkyong.com/spring-batch/spring-batch-unit-test-example/|Spring Batch unit test example – Mkyong.com]]
 +  * [[http://hwannnn.blogspot.com/2018/06/spring-batch-test-joblaunchertestutils_5.html|JobLauncherTestUtils를 이용한 Spring Batch Test]]
 +
  
 ===== 참고 ===== ===== 참고 =====
   * [[https://dzone.com/articles/spring-batch-with-quartz|Run a Spring Batch Job With Quartz]]   * [[https://dzone.com/articles/spring-batch-with-quartz|Run a Spring Batch Job With Quartz]]
   * [[https://www.youtube.com/watch?v=CYTj5YT7CZU&feature=youtu.be|Spring Batch (Michael Minella) - YouTube]]   * [[https://www.youtube.com/watch?v=CYTj5YT7CZU&feature=youtu.be|Spring Batch (Michael Minella) - YouTube]]
springframework/batch.txt · 마지막으로 수정됨: 2023/12/08 13:43 저자 kwon37xi