Mybatis报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题解决办法汇总

今天遇到了这个错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found),结果查询出来的办法如下:

  1. mybatis的xml文件的命名空间写错,命名空间应该是xml对应的数据接口类。
    例如:类名是com.xxx.dao.MyMapper接口,那么xml就应该配置成
  2. mybatis的xml文件中没有数据接口类中接口对应的方法,或者方法参数有误。
    例如:接口类中定义了public List listMyBean(MyBean bean),那么xml中应该有<select id="listMyBean" parameterType="com.xxx.bean.MyBean" resultType="com.xxx.bean.MyBean"></select>的标签
  3. mybatis的xml和数据接口类所在的包一致,或者配置mybatis.mapper-locations参数。
    例如: 如果类名是com.xxx.dao.MyMapper接口,那么对应方式的xml有如下配置:
    a. xml放在resources目录下的com/xxx/dao/MyMapper的目录下;
    b. xml放在resources目录下的指定目录下(例如mapper目录),则在application.xml中指定mybatis.mapper-locations(例如:mybatis.mapper-locations= classpath:/mapper/*.xml)
    或者在application.yml中指定
    mybatis:
    mapper-locations: classpath:/mapper/*.xml
    这个样子。
posted @ 2020-06-04 09:58  神奇小宝  阅读(275)  评论(0编辑  收藏  举报