개발자 공부 업무 정보/DEBUG

Mapped Statements collection does not contain value

회님 2023. 2. 16. 21:36
반응형

mybatis 에러 디버그

 

IllegalArgumentException: Mapped Statements collection does not contain value

 

번역 : 매핑된 문 컬렉션에 다음에 대한 값이 없습니다.

 

 

 

해당 오류는 여러가지 원인이 있지만 대표적인 원인들과 해결 방안을 정리한다

 

1.   Set mapperLocation property in your SqlSessionFactory bean

 

mapper의 bean name 설정을 확인해봐야한다.

 

<property name="mapperLocations" 
value="classpath*:pathWhereYouHaveMapper/*Mapper.xml" /> 

 

Mapper 의 위치가 루트부터 차근차근 확인하고 루트가 다르다면 수정하여 다시 테스트해보자

 

2. SQL Syntax (maybe a single small query has an extra "" at the end of the select)

 

에러를 발생시키는 쿼리문의 쿼리 오류를 확인해봐야 한다.

,  등의 기호가 들어가 있을 수 있다. 개인적으론 쿼리를 긁어 현재 보고있는 툴외의 메모장등으로 복사해와서 보는걸 추천.

 

3. most importantly you should use same names

 

가장 중요한 것은 파일명을 전부 동일하게 가져가야한다.

 

ex)

  • interface = xxx.yyy.mappers.SettingMapper.class
  • mapper file = /xxx/yyy/mappers/SettingMapper.xml
  • mapper namespace = xxx.yyy.mappers.SettingMapper

 

 

반응형