콘솔 창에 뜬 오류를 살펴보자..

ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/spring/action-mybatis.xml]: 
Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 
'file [C:\work_sts.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\shopTranSpring\WEB-INF\classes\mybatis\mappers\address.xml]'; nested exception is java.lang.RuntimeException: 
Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: 
Error resolving class . Cause: org.apache.ibatis.type.TypeException: 
Could not resolve type alias ''.  Cause: java.lang.ClassNotFoundException: 
Cannot find class:

 

오류 메세지를 보면

MyBatis의 매퍼 XML 파일(address.xml)을 파싱하는 도중에 문제가 발생했다고 한다.

 

java.lang.ClassNotFoundException: Cannot find class:를 보면 특정 클래스를 찾지 못했다고 한다.

매퍼 XML 파일 내에서 사용된 type alias가 잘못 지정되었을 가능성이 크다.

address.xml 파일을 확인해보자.

VO 클래스를 불러오는 과정과 반환 타입을 설정하는 부분 오타 실수가 있었다..ㅎ 
가장 많이 내는 오타로 인한 실수 주의하자!

 


수정된 코드

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
      PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
   "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="mapper.address">
	<resultMap id="addResult" type="com.team6.sts.vo.AddressVO">
		<result property="zip_num" column="zip_num" />
		<result property="sido" column="sido" />
		<result property="gugun" column="gugun" />
		<result property="dong" column="dong" />
		<result property="zip_code" column="zip_code" />
		<result property="bunji" column="bunji" />
	</resultMap>
	
	<!-- findZip -->	
 	<select id="selectZip" parameterType="String" resultMap="addResult" > 
			<![CDATA[
				select * from address
				where dong like '%'||#{dong}||'%'
			]]>			
 	</select> 
</mapper>

 

+ Recent posts