멀티 모듈 프로젝트에 OpenFeign을 적용하고 다음과 같은 Exception이 발생하는 상황이 생겼습니다.
The bean 'exampleService.FeignClientSpecification' could not be registered.
Bean already defined and overriding is disabled
구글링을 해보니 우선 첫번째 해결 방법은 FeignClient 어노테이션 선언 부분에 중요된 name 이나 contextId가 있는지 확인해 보라는
내용 이었습니다.
@FeignClient(name="ExampleService_1", configuration = FeignClientConfig.class, url = "http://localhost:8091")
@FeignClient(name="ExampleService_2", configuration = FeignClientConfig.class, url = "http://localhost:8091")
하지만 기존 로직에 contextId 속성은 정의하지 않았고 name도 중복되지 않았습니다.
현재 상황에서 contextId를 추가해도 동일했습니다.
결국 원인을 찾다보니 멀티 모듈에서 모듈별로 @EnableFeignClients 를 선언하다 보니 중복에 의한 원인이 이슈였습니다.
** 해결방법 : application.yml에 중복 설정을 해도 오버라이딩이 허용하도록 설정을 추가하여 해결했습니다.
spring.main.allow-bean-definition-overriding=true
'Spring' 카테고리의 다른 글
CommandLineRunner을 이용하여 특정 클래스 수행하기 (0) | 2023.05.17 |
---|