본문 바로가기
IT/Java

spring annotation-driven 시 bean name 중복(충돌,conflicts) 해결

by 성준하이 2022. 12. 4.
반응형

spring은 annotation-driven component scan 시 기본적으로 Bean 이름으로 id를 결정한다.(annotation으로 설정)

예를 들어 클래스명이 TestController 라면 id는 “testController” 로 결정된다.

이때 다른 패키지에서 동일한 이름을 가진 클래스(컴포넌트)가 중복으로 존재한다면 동일한 id 를 가지게 되며 아래와 같은 에러 메시지를 볼 수 있다.

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [.....\servlet-context.xml]; 
nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'cblController' for bean class [......CblController] conflicts with existing, 
non-compatible bean definition of same name and class [......CblController]

 

Bean 의 이름이 겹칠때 해당 에러가 발생하니 이럴경우엔 클래스의 이름 중복이나 Bean설정 이름 부분을 확인해주면 된다.

반응형

'IT > Java' 카테고리의 다른 글

JPA query Keyword (repository)  (34) 2022.12.06
JPA메서드 save 와 saveAndFlush 비교  (32) 2022.12.05
JPA 더티체킹(Dirty Checking) 이란?  (37) 2022.12.03
List 와 map 에 대해서  (30) 2022.12.02
자이썬(Jython) 이란?  (40) 2022.12.01

댓글