Java/Spring
[Spring 오류] Failed to parse mapping resource 해결
펜네임
2020. 5. 22. 10:11
어제 xml 파일을 수정하고 아침에 돌아와 프로젝트를 RUN하니 404 오류가 뜬다.
이클립스에서는 아래와 같은 오류메시지 출력.
오류메시지
cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DAO이름': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commonMapper': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSession' defined in file [상세주소\context-mapper.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [상세주소\XML파일 이름.xml]'; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for 네임스페이스 이름.쿼리 ID
오류 원인 및 해결법
아래 예시처럼 해당 xml파일에 중복되는 ID가 있었다.
오류메시지에 중복되는 ID가 뜨니 이걸 바꿔주면 해결!
<select id="selectApple" resultType="String">
SELECT *
FROM dbo.PRUITS
WHERE PRUIT_ID = '001'
</select>
<select id="selectApple" resultType="String">
SELECT *
FROM dbo.MEMBER
WHERE NAME = 'pennek'
</select>