栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Mybatis:Type interface com.itheima.dao.IUserDao is not known to the MapperRegistry.解决方案

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Mybatis:Type interface com.itheima.dao.IUserDao is not known to the MapperRegistry.解决方案

目录

项目场景开发环境描述问题描述解决方案原因分析其他可能出现的错误参考文献写在后面

项目场景

最近,在跟着黑马IT的视频学习mybatis,现记录如下

开发环境描述

IDEA版本:20201.1
JDK版本:jdk1.8.0_181、jdk-14.0.2、jdk-16.0.1
Maven版本:apache-maven-3.5.2

该问题出现在以上版本,并成功解决。

问题描述

出现报错:Type interface com.itheima.dao.IUserDao is not known to the MapperRegistry.

解决方案

核对 SqlMapConfig.xml 中信息径发现并无异常,最终发现自己的 namespace 写错了。

修改 namespace

再次运行,成功解决

原因分析

一般出现 Type interface com.itheima.dao.IUserDao is not known to the MapperRegistry. 异常时,我们应该安装以下步骤进行排查:

    检查 SqlMapConfig.xml 中有没有配置 mapper 路径检查 SqlMapConfig.xml 中 resource 指定位置是都有误检查路径中的 namespace 是否配置错误
其他可能出现的错误

需要注意,如果报错是org.apache.ibatis.exceptions.PersistenceException:### Error querying database. 需要根据后面的 Cause:xxx来判断错误类型

resultType 配置错误的话,会报 Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating interface com.itheima.dao.IUserDao with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.itheima.dao.IUserDao.() 异常

sql语句错误的话,会报 Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'eesy_mybatis.usr' doesn't exist 异常

参考文献

1.Mybatis:Type interface com.itheima.dao.IUserDao is not known to the MapperRegistry.解决方案

写在后面

欢迎随时留言讨论,知无不答!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/733039.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号