报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

解决方案/检查顺序:

1.检查application.yml文件中配置是否正确
在这里插入图片描述

2.检查文件路径是否正确,且UserMapper.java文件名要和UserMapper.xml文件名相同
在这里插入图片描述

3.检查Mapper类

在这里插入图片描述

4.检查Service接口

在这里插入图片描述

5.检查实现类
在这里插入图片描述

使用自定义sql语句:

1.自定义查询语句select

<select id="findCustomerById" parameterType="Integer" resultType="com.itheima.po.Customer">
     select * from t_customer where id = #{id}
</select>

常用参数说明:

​ id:与Mapper类中的方法名对应

​ resultType:sql语句的返回值类型(参数为全限定名或别名)

​ parameterType:传入sql语句中参数(参数为全限定名或别名;可以不用加,默认参数会对应上)

ps:我是定义自定义sql语句时踩到第一种情况的坑,用的是mybatis-plus,但路径定义的是mybatis。直接使用mybatis-plus自带的方法并不会报错,但使用自己定义的方法,它得去找到该方法,才报的not found。


版权声明:本文为niceday_007原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。