很多朋友在使用Mybatis通过获取mapper发送SQL语句时总会遇到这样的错误,这是因为mapper映射文件的namespace所引起的,解决方案就是修改mapper的namespace为相应的dao文件即可。
org.apache.ibatis.binding.BindingException: Type interface dao.IStudentDao is not known to the MapperRegistry.
如下所示:
<mapper namespace="dao.IStudentDao">
<!-- id是该sql语句的名字, parameterType是 -->
<insert id="insertStu" parameterType="mybatis.Student">
insert into
student(name,age,score) values(#{name}, #{age}, #{score})
</insert>
</mapper>
解决Mybatis BindingException错误
本文详细解析了在使用Mybatis框架时常见的BindingException错误,通常由mapper映射文件的namespace配置不当引起。文章提供了具体的解决方案,即确保mapper的namespace与对应的dao文件相匹配,附带示例代码帮助读者快速定位并解决问题。
1808

被折叠的 条评论
为什么被折叠?



