본문 바로가기

Dev. Debug/프로그램

[오류-mvc] Could not resolve type alias ''

에러

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'template' defined in ServletContext resource [/WEB-INF/first-servlet.xml]: Cannot resolve reference to bean 'factoryBean' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'factoryBean' defined in ServletContext resource [/WEB-INF/first-servlet.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\_KSH_Dev\sts_workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\_testPrj\WEB-INF\classes\_sqlMap\MemberMap.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: 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:


해결법

MapperConfig에 해당 클래스가 없을 때 발생하는 에러이다.

MapperConfig에 해당 클래스의 alias를 추가 해주면 오류가 해결된다.

반대로 MapperConfig에 올바르지 않은 패키지의 클래스가 있어도 sqlSessionFactory 에러가 발생한다.

이럴 경우 주석을 걸거나 올바른 패키지 주소로 바꿔주면 된다.