MyBatis Error:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)(IDEA)...

JDK:1.8

项目结构:

MyBatis Error:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)(IDEA)...

MyBatis:依赖

MyBatis Error:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)(IDEA)...

遇到问题:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

解决方法:

①确保mybatis-config、mapper.xml中的映射路径正确;

②看target目录下是否有对应的mapper.xml,如果没有,就在resource目录下创建一个mapper路径

并把mapper.xml剪切进去。注意!在java文件夹下的xml是扫描不到的,所以编译后target中的mapper中(如3处)没有StudentMapper.xml。在将1处的Mapper.xml剪切入2处后,再次编译,3处会出现mapper.xml。

MyBatis Error:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)(IDEA)...

 

③重点来了!!!一般情况下到这里已经解决了可是我还是有BindingException错误。接下来我修改了一下mapper.xml的文件名。

MyBatis Error:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)(IDEA)...

原来我是通过这种方式创建xml的,所以生成的xml如下图

MyBatis Error:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)(IDEA)...

没有.xml后缀,我给文件名加上了后缀.xml后程序完美运行!!!

完美运行!!!

留个赞吧~(●'◡'●)~

转载于:https://my.oschina.net/codelx/blog/1587068