问题描述
刚为了搞一个东西,建了个SpringBoot的小demo,在启动后,调用查询接口,报以下错误:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.myspringboot.springboottest.dao.StudentDao.queryStudent
如下图:
问题分析
通过报错可以看出,是未和其对应的Dao类绑定上。其他都没问题,检查我的配置后发现在配置文件中未指定mapper文件的路径。
解决方式
查看自己Mapper.xml文件所在位置,根据自己的实际情况在配置文件中指定mapper文件的路径。我的如下:
在application.yml
中添加以下配置即可:
mybatis:
mapper-locations: classpath:mapper/*.xml