mybatis报错:Invalid bound statement (not found)
mybatis报错,找不到mapper.xxx方法
1.启动类要加@MapperScan(“存放mapper接口的路径”)
2. mapper.xml映射文件中namespace(命名空间)的路径
<mapper namespace="mapper接口的路径">
3 mapper.xml映射文件中方法名
<select id="mapper接口的方法名" resultType="返回类型">
select * from table_name
</select>
4 mapper接口名 与 mapper.xml(映射文件)名 不一致
(我就遇到这个错误)
5. mapper接口文件夹 与 mapper映射文件夹的路径要一致(如果不一致需要配置,具体配置网上有很多)
在查错中,发现mapper接口不加 @Mapper 注解 不影响代码正常运行
//@Mapper
public interface SortProducMapper {
List<SortProduct> findAll();
}
可以用Ctrl+鼠标左键,来查看路径是否正确。
自己在开发中遇到的坑,记录一下。如有不对,欢迎指正