본문 바로가기
Spring Batch

spring.main.allow-bean-definition-overriding: true 에러 해결

by 코리늬 2019. 3. 20.

스프링 배치를 실행하던 중

createQueryProvider라는 bean을 생성하는 과정에서 에러가 발생했다.


에러내용은 아래와 같다.

Description:

The bean 'createQueryProvider', defined in class path resource [com/example/batch/seokhun/processor/ProcessorConvertJobConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [com/example/batch/seokhun/Reader/JdbcPagingItemReaderJobConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true


에러 원인

다른곳에서 이미 해당 bean을 생성해서 중복이 되는현상


해결

스프링부트 2.1 부터는 overriding 옵션이 false로 default 설정이 된다고한다. 그래서

Bean Overriding을 활성화 하기 위해 application.yml에 spring.main.allow-bean-definition-overriding: true 옵션 추가.



댓글