Spring Batch Environment Setting

From JCFWiKi

Jump to: navigation, search

그림:check.gif

  • 산출물: Spring Batch Environment Setting
  • 작성자: 서경진
  • 최초작성일 : 2008/07/24
  • 최종작성일 : 2008/07/30

Copyright © 2008 Daewoo Information Systems Co., Ltd.

그림:information.gif

  • 이 문서에는 Spring Batch 코어와 샘플 프로젝트를 설치하고 구동하는 것을 설명할 것이다.

그림:forbidden.gif

  • 이 문서는 현재 작성중에 있습니다.

목차

[편집] 프로젝트 다운받기

  • Spring Batch에 대한 이해를 높이기 위해서 Spring Batch에서 제공하는 소스와 샘플을 설치하여 테스트하는 것이 필요하다.
  • 우선 프로젝트를 구성하기 위해 Spring Batch SVN 사이트(http://springframework.svn.sourceforge.net/svnroot/springframework/spring-batch) 에서 소스를 다운로드 받는다.
  • Eclipse에서 다음과 같이 Repository를 설정한다.
Spring Batch SVN Site
Spring Batch SVN Site
  • 해당 URL을 통해 접근하면 다음과 같은 디렉토리 구조를 가지는 것을 확인할 수 있다.
Spring Batch 디렉토리 구조
Spring Batch 디렉토리 구조
  • SVN 디렉토리 구조에서 trunk에서 오른쪽 버튼을 클릭하여 소스를 checkout 한다.
  • Spring Batch와 관련된 모든 소스들이 Checkout 되고 로컬 프로젝트 디렉토리 구조는 다음과 같다.
로컬 프로젝트 디렉토리 구조
로컬 프로젝트 디렉토리 구조

[편집] Eclipse 프로젝트로 Import하기

  • Package Explorer View에서 오른쪽 마우스를 클릭하고 출력된 메뉴에서 Import를 선택한다.
  • Import창에 다음과 같이 설정하고 spring-batch-core 프로젝트를 생성한다.

  • 마지막 그림에서 finish를 클릭하면 eclipse의 explorer view에 다음과 같이 spring-batch-core 프로젝트가 등록된 것을 확인할 수 있다.
eclipse 프로젝트 등록
eclipse 프로젝트 등록
  • spring-batch에 있는 서브 디렉터리인 spring-batch-infrastructure, spring-batch-integration, spring-batch-samples도 위와 같은 방법으로 eclipse 프로젝트로 등록한다.
  • 다음은 spring-batch의 서브 프로젝트를 eclipse 프로젝트로 등록한 화면이다.
spring-batch 서브 프로젝트를 eclipse 프로젝트로 등록
spring-batch 서브 프로젝트를 eclipse 프로젝트로 등록

[편집] Maven 명령으로 실행하기

  • 현재 eclipse에 등록된 spring-batch 프로젝트는 POM (Project Object Model) 기반의 Maven 프로젝트이다.
  • Maven 기반의 프로젝트를 구동시키기 위해 Maven과 M2 Plugin을 설치하는 것이 필요하다.

[편집] Maven과 M2 Plugin 설치하기

  • 아래의 JCF tutorials의 개인 개발환경에서 지시하는 내용에 따라 개발환경을 구성한다.

그림:information.gif

  • JCF 개인 개발환경 구성: 이동

[편집] 로컬 라이브러리 저장소로 install하기

  • 개인 개발환경이 구성되면 Maven과 M2 Plugin의 사용이 가능하다.
  • spring-batch-infrastructure로부터 spring-batch-samples까지 M2 eclipse를 활용하여 다음과 같이 install한다.
1. install의 순서
1) spring-batch-infrastructure
2) spring-batch-core (spring-batch-infrastructure에 대한 dependency 존재)
3) spring-batch-samples
4) spring-integration-batch (Optional)

[편집] spring-batch-infrastructure

  • 다음과 같이 Maven install 명령을 실행하여 spring-batch-core가 install 될 수 있는 환경을 구축한다.
spring-batch-infrastructure 프로젝트의 Run as 메뉴에서 Maven install 실행하기
spring-batch-infrastructure 프로젝트의 Run as 메뉴에서 Maven install 실행하기
  • Maven install 명령을 실행하면 다음과 같이 시작하며 task-segment: [install]은 다음과 같은 순서로 task를 처리한다.
1. resources:resources
2. compiler:compile
3. resources:testResources
4. compiler:testCompile
5. surefire:test
6. jar:jar
7. source:jar
8. bundle:manifest
9. install:install
  • Maven install이 시작되었을 때의 콘솔화면이다.
install 시작
install 시작
  • Maven install이 종료되었을 때의 콘솔화면이다.
install 종료
install 종료

[편집] spring-batch-core

  • spring-batch-core는 다음과 같이 spring-batch-infrastructure에 대한 dependency가 존재한다.
<dependency>
	<groupId>org.springframework.batch</groupId>
	<artifactId>spring-batch-infrastructure</artifactId>
	<version>${project.version}</version>
</dependency>
spring-batch-core 프로젝트의 Run as 메뉴에서 Maven install 실행하기
spring-batch-core 프로젝트의 Run as 메뉴에서 Maven install 실행하기
  • Maven install을 클릭하면 콘솔 View에 다음과 같이 install task의 시작을 알린다.
  • Maven install 명령을 실행하면 다음과 같이 시작하며 task-segment: [install]은 다음과 같은 순서로 task를 처리한다.
1. antrun:run
2. resources:resources
3. compiler:compile
4. resources:testResources
5. compiler:testCompile
6. surefire:test
7. jar:jar
8. statemgmt:start-fork
9. antrun:run
10. statemgmt:end-fork
11. source:jar
12. statemgmt:clear-fork-context
13. bundle:manifest
14. install:install
  • Maven install이 시작되었을 때의 콘솔화면이다.
install 시작
install 시작
  • Maven install이 종료되었을 때의 콘솔화면이다.
install 종료
install 종료

[편집] spring-batch-samples

  • samples는 spring-batch-infrastructure와 spring-batch-core에 대한 dependency를 가지고 있다.
  • 따라서 spring-batch-infrastructure와 spring-batch-core에 대한 install이 선행된 후에 samples에 대한 install이 가능하다.
  • 다음은 spring-batch-samples 프로젝트에 있는 pom.xml 파일의 dependency의 일부분이다.
<dependency>
	<groupId>org.springframework.batch</groupId>
	<artifactId>spring-batch-core</artifactId>
	<version>${project.version}</version>
</dependency>
<dependency>
	<groupId>org.springframework.batch</groupId>
	<artifactId>spring-batch-infrastructure</artifactId>
	<version>${project.version}</version>
</dependency>
  • spring-batch-samples 프로젝트도 다른 프로젝트와 마찬가지로 Maven install을 실행한다.
  • Maven install이 실행하면 task-segment: [install]은 다음과 같은 순서로 task를 처리한다.
1. antrun:run
2. resources:resources
3. compiler:compile
4. resources:testResources
5. compiler:testCompile
6. surefire:test
7. jar:jar
8. statemgmt:start-fork
9. antrun:run
10. statemgmt:end-fork
11. source:jar
12. statemgmt:clear-fork-context
13. install:install
  • Maven install이 시작되었을 때의 콘솔화면이다.
install 시작
install 시작
  • Maven install이 종료되었을 때의 콘솔화면이다.
install 종료
install 종료

[편집] test 실행하기

  • Maven install 이후에 Maven에 대하여 다음과 같이 선택적인 실행이 가능하다.
1. Maven build
2. Maven build...
3. Maven clean
4. Maven generate-sources
5. Maven install
6. Maven test
  • 따라서 test만 실행하기 위해서는 Maven test를 실행하여 콘솔을 통해 실행과정을 모니터링할 수 있다.
  • 각 TestCase를 별도로 실행하는 것도 가능하다.

[편집] 주요 TestCase 이해하기

[편집] 별도로 spring-batch TestCase 실행시키기