Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error par

关于使用Mybatis的报错问题描述:

Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: 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 ‘StudentTeacher’. Cause: java.lang.ClassNotFoundException: Cannot find class: StudentTeacher
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:80)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:64)
at util.MybatisUtil.getSqlSessionFactory(MybatisUtil.java:20)
at util.MybatisUtil.getSession(MybatisUtil.java:25)
at dao.StudentDao.getAll(StudentDao.java:13)
at test.TestOneToMany.main(TestOneToMany.java:15)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: 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 ‘StudentTeacher’. Cause: java.lang.ClassNotFoundException: Cannot find class: StudentTeacher
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:121)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:99)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:78)
… 5 more
Caused by: 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 ‘StudentTeacher’. Cause: java.lang.ClassNotFoundException: Cannot find class: StudentTeacher
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:120)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:92)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:373)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:119)
… 7 more
Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘StudentTeacher’. Cause: java.lang.ClassNotFoundException: Cannot find class: StudentTeacher
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:118)
at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:74)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:135)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:118)
… 10 more
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘StudentTeacher’. Cause: java.lang.ClassNotFoundException: Cannot find class: StudentTeacher
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)
… 14 more
Caused by: java.lang.ClassNotFoundException: Cannot find class: StudentTeacher
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:200)
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)
… 16 more

解决问题如下:

1. 先看一下你有没有使用ResultMap的来定义返回的结果集合,如果有的话看一下你的那个配置xmlSQL语句映射的的那个返回集结果类型是resultType还是resultMap类型的,如果是resultType类型的话,那就对了,把resultType改成resultMap类型,应该就对了。

2. 原因是:当你使用自定义的resultMap为返回的结果集的时候,你没有把SQL语句的那个xml文件中的那个resultType改成resultMap,导致找不到你自定义的那个resultMap的结果集的id,也就是 Cause: java.lang.ClassNotFoundException: Cannot find class: <这里就是你的自定义resultMap的id名>

你可能感兴趣的:(WHAT,FUCKING,BUG)