[Solved] Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException

The following errors are reported using Mybatis.

Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is ‘com/kq/dao/UserMapper.xml’. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘UserMap’. Cause: java.lang.ClassNotFoundException: Cannot find class: UserMap
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:122)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:99)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:78)
… 25 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is ‘com/kq/dao/UserMapper.xml’. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘UserMap’. Cause: java.lang.ClassNotFoundException: Cannot find class: UserMap
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:123)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:95)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:377)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:120)
… 27 more
Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘UserMap’. Cause: java.lang.ClassNotFoundException: Cannot find class: UserMap
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:118)
at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:102)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:138)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:131)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:121)
… 30 more
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘UserMap’. Cause: java.lang.ClassNotFoundException: Cannot find class: UserMap
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:120)
at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:149)
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:116)
… 34 more
Caused by: java.lang.ClassNotFoundException: Cannot find class: UserMap
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:196)
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:89)
at org.apache.ibatis.io.Resources.classForName(Resources.java:261)
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:116)
… 36 more

 

Solution:

1. first look at whether you have used the ResultMap to define the returned result set, if so, look at your configuration of the xmlSQL statement mapping the return set result type is resultType or resultMap type, if it is the resultType type, then it is right, change the resultType to resultMap type, it should be right. 2.
The reason is: when you use the custom resultMap for the returned result set, you did not change the SQL statement in the xml file of the resultType to resultMap, resulting in not finding the id of the result set of your custom resultMap, that is, Cause: java.lang. ClassNotFoundException: Cannot find class: <here is the id name of your custom resultMap>.

Read More: