Mybatis报错:Type interface com.mycode.dao.UserMapper is not known to the MapperRegistry.

问题描述:
MapperRegistry不知道 com.mycode.dao.UserMapper这个接口。
在这里插入图片描述
解决思路:
在这里插入图片描述
以上图示代码首先是读取核心配置文件(SqlMapConfig.xml),得到一个输入流,构造者根据输入流流构造一个工厂,工厂生产一个SqlSession对象,SqlSession对象得到映射器的代理对象(有接口,没有实现类,生成代理对象),由代理对象执行sql语句。而报错是MapperRegistry不知道 com.mycode.dao.UserMapper这个接口,所有先看一下映射配置文件(UserMapper.xml)中namespace属性,namespace属性是规定给那个接口配置的映射。
在这里插入图片描述
这是就发现了问题。。。。写习惯了Dao,这里的接口名写错了

发布了48 篇原创文章 · 获赞 18 · 访问量 2932

猜你喜欢

转载自blog.csdn.net/qq_45615417/article/details/104736685