eGovFrame 표준프레임워크 포털

메뉴 건너띄기
상단메뉴 바로가기
본문 바로가기

이 누리집은 대한민국 공식 전자정부 누리집입니다.

본문 영역

적용 지원, FAQ, Q&A 게시판을 통해 기술 문제 해결을 지원합니다.

묻고 답하기

Boot Batch Template Project 관련 오류 입니다.
  • 작성자

    이*민

  • 작성일

    2023-10-20 02:00:59

  • 조회수

    931

  • 구분

    개발환경 / 4.0

  • 진행상태

    완료

질문

안녕하세요.

Boot Batch Template Project 를 이용하여

DB (SQLite) to DB (Oracle) 배치를 구성하려고 합니다.

Web 서비스 방식이며 JdbcTojdbc 형태의 job으로 등록하여 실행하니 다음과 같은 오류가 발생하였습니다.

[오류내용]

... 생략 ...
[D:\dev\cdu\workspace\batch\target\classes\egovframework\batch\context-batch-job-launcher.xml]: Cannot resolve reference to bean 'jobRepository' while setting bean property 'jobRepository'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration$DataSourceInitializerConfiguration.class]: Unsatisfied dependency expressed through method 'batchDataSourceInitializer' parameter 0; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected single matching bean but found 2: dataSource-sqlite,dataSource-oracle

Parameter 0 of method batchDataSourceInitializer in org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration$DataSourceInitializerConfiguration required a single bean, but 2 were found:
- dataSource-sqlite: defined in class path resource [egovframework/batch/context-batch-datasource.xml]
- dataSource-oracle: defined in class path resource [egovframework/batch/context-batch-datasource.xml]

Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

multi datasource 형태로 배치를 구성하여 발생한 오류 같은데
각 각의 datasource를 중복된 bean으로 인식하는 문제를
xml형태로 구성되어 어찌 해결해야 할지 모르겠습니다.

각 설정파일을 첨부하오니, 바쁘시겠지만 검토 부탁드립니다.

감사합니다.

환경정보
    - OS 정보 : Windows 10
    - 표준프레임워크 버전 : 4.0
    - JDK(JRE) 정보 : 16
    - WAS 정보 : tomcat
    - DB 정보 : oracle & SQLite
첨부파일
답변

안녕하세요.
표준프레임워크센터입니다.

다중 DB를 써야하는 상황이라면, DataSource를 다중으로 설정하셔야 합니다.
그리고 다중 설정한 DataSource를 Reader와 Writer에 각각 상황에 맞게 주입하셔서 사용하면 됩니다.

context-batch-datasource.xml 추가 dataSource Bean을 등록 후
ItemReader 설정과 itemWriter 상의 dataSource property 부분을 각각 다른 dataSource로 지정하시면 됩니다.

다중 dataSource 설정에 관련하여서는 포털사이트의 예제다운로드 페이지에서
[실행환경 MultiDataSource 예제] 를 참고하시면 도움이 될 것으로 보입니다.
https://www.egovframe.go.kr/home/sub.do?menuNo=37#

감사합니다.

이 페이지의 구성

묻고 답하기