Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- baeldung
- 구멍가게코딩단
- 처음 만나는 AI 수학 with Python
- 친절한SQL튜닝
- 자료구조와함께배우는알고리즘입문
- 자바편
- iterator
- 티스토리 쿠키 삭제
- 코드로배우는스프링웹프로젝트
- 자료구조와 함께 배우는 알고리즘 입문
- resttemplate
- 목록처리
- 처음 만나는 AI수학 with Python
- 알파회계
- 이터레이터
- d
- 코드로배우는스프링부트웹프로젝트
- 스프링 시큐리티
- /etc/network/interfaces
- GIT
- 스프링부트핵심가이드
- ㅒ
- 서버설정
- 페이징
- network configuration
- 데비안
- 네트워크 설정
- Kernighan의 C언어 프로그래밍
- 리눅스
- 선형대수
Archives
- Today
- Total
bright jazz music
Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for + was(Tomcat) 캐시 제거 본문
오류
Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for + was(Tomcat) 캐시 제거
bright jazz music 2022. 8. 9. 17:48오류
Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource
~~
Mapped statements collection already contains value for 네임스페이스명.쿼리id
~~
- 마이바티스를 사용하는 경우, 쿼리 아이디가 중복됨으로써 발생하는 문제이다.
내 경우 아래와 같은 에러 로그가 발생하였다.
오류 분석
20220729 21:16:33.552[ localhost-startStop-1] WARN o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedD bean with name 'xxxxxxxxxxController': Unsatisfied dependency expressed through field 'xxxxxxxxxxService';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'xxxxxxxxxxServiceImpl':through field 'xxxxxxxxxxMapper';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'xxxxxxxxxxMapper' defined in file [/usr/local/apache-tomcat-8.5.81/webapps/ROOT/WEB-INF/classes/coass]:
Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sqlSessionFactory' defined in class path resournfigure/MybatisAutoConfiguration.class]:Bean instantiation via factory method failed; nested exception is org.springframework.beans
BeanInstantiationException: Failed to instantiate
[org.apache.ibatis.session.SqlSessionFactory]: Factoryexception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [/usr/local/apache-tomcat-8.5.81/webapps/ROOT/WEB-INF/classes/com/xxxxxxxxxxproject/db/xxxxxxxxxxMappler.xml]'; nested exception is org.aion: Error parsing Mapper XML.
Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.xxxxxxxxxx.xxxxxxxxxx.mapper.xxxxxxxxxxMapper.xxxxxxxxxxMap
- 결국 아래의 순서로 연쇄적인 오류가 발생한 것이다.
- xxxxxxxxxxMapper에 중복된 Value 존재.
- xxxxxxxxxxMapper.xml 파싱 실패 (중복이 존재하므로)
- xxxxxxxxxxMapper의 Bean 생성 실패 (파싱에 실패 했으므로)
- xxxxxxxxxxServiceImpl의 Bean 생성 실패 (여기에 주입돼 있는 xxxxxxxxxxMapper의 Bean생성에 실패 했으므로)
- xxxxxxxxxxService의 Bean 생성 실패 (여기에 주입돼 있는 xxxxxxxxxxMapper의 Bean생성에 실패 했으므로)
- xxxxxxxxxxController의 Bean 생성 실패 (여기에 주입돼 있는 xxxxxxxxxxService의 Bean생성에 실패 했으므로)
- context initialization 실패
해결 방법
- 해당 xml 파일의 중복을 제거하면 된다. 중복된 value를 지우든지 주석처리하면 된다.
그런데 해당 xml 파일에 중복이 없는 경우에도 위 오류가 발생한다면 어떻게 해야 할까?
동일한 내용이 있는 파일이 존재하는지 확인하라.
- 아무리 찾아봐도 xxxxxxxxxxMapper.xml 에 중복된 아이디가 존재하지 않는다.
- 그렇다면 다른 파일에 동일한 아이디를 가진 파일이 존재할 수도 있다.
- 내 경우 백업용으로 xxxxxxxxxxMapper2.xml을 생성한 것을 잊어버려서 시간을 허비한 경험이 있다.
- 위 오류를 '하나의 파일에 동일한 아이디가 존재하여 발생하는 오류'라는 생각에 사로잡히면 주위를 둘러보기 어렵다.
아, 역시 동일한 내용을 담은 파일이 존재했다. 이 녀석을 삭제했다. 그런데 이 파일을 제거한 이후에도 동일한 오류가 발생한다면 어떻게 해야 할까?
Web Application Server(was)의 cache를 청소(clean)하라.
was에 캐시가 남아 있는 경우, 이전의 설정 때문에 동일한 오류가 발생할 수 있다.
내 경우 was는 톰캣, IDE는 인텔리제이를 사용하고 있다. 인텔리제이에서는 아래의 방법으로 was 캐시를 제거할 수 있다.
1. 상단 메뉴에서 Build - Build Artifacts... 선택
2. 화면 중앙에 다음과 같은 창이 생성되면 clean 하기를 원하면 원하는 아티팩트를 clean한다. All Artifacts를 선택하고 clean을 하면, Was상의 모든 프로젝트의 캐시가 제거된다.
'오류' 카테고리의 다른 글
Comments