Mapped Statements collection already contains key 에러

codemin·2024년 11월 15일

trouble_shooting

목록 보기
3/7

에러 메세지

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ExchangeControllerQuery'  ~ (생략)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ExchangeServiceQuery' ~(생략)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exchangeMapper' ~(생략)
Caused by: java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'com/varc/brewnetapp/domain/exchange/query/mapper/ExchangeMapper.xml' ~ (생략)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML ~ (생략)
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains key  ~ (생략)

에러 메시지를 살펴보니 맨 마지막에 Mapped Statements collection already contains key~ 라는 에러를 확인할 수 있었다.

원인

MyBatis에서 XML Mapper 파일을 파싱할 때, 동일한 ID(Key)를 가진 매핑 문(statement)이 이미 존재해서 발생한 문제였다.

해결

Mybatis용 ExchangeMapper.xml을 확인해 보니

<select id="selectFranExchangeList" resultType="int">

이 부분에 동일한 id를 가진 쿼리가 2개 있었다.
id를 다른 것으로 변경해서 에러를 해결했다.

0개의 댓글