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

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

viEcho Lv5

最近自己写了个小项目:vBills 一个单体的账单可视化系统;因为用了mybatis-plus,所以开发起来很便捷;但是一些稍微复杂一点的查询还是得自己手写sql,然后就自己写了个查询,自测时发现dao层和xml文件映射不上,就这个点上卡了一个多小时,笑try~

报错如下

排查过程如下

  • 检查dao层文件名和xml文件名是否一致
  • 检查xml中nameSpace 路径是否正确
  • 检查dao查询方法名和xml中查询id 是否一致
  • 检查mybatis 配置 是否指定对应的xml文件映射路径
  • 检查pom文件中 build标签中依赖的resource是否包含了xml文件(一般不用配置即包含所有资源)

mybatis配置如下

1
2
3
4
5
6
7
## 实体类和mapper配置
mybatis:
type-aliases-package: com.vbills.entity
mapper-locations: classpath:mapper/*Mapper.xml,mapper/*/*Mapper.xml
configuration:
#当查询数据为空时字段返回为null,不加这个查询数据为空时,字段将被隐藏
call-setters-on-nulls: true

思考

就按照上面的排查了一圈发现没啥问题啊,尼玛咋就不行了呢?猛然想起用的是mybtais-plus,pom文件中还有mybatis-plus的配置;莫非映射文件的地址应该配置到mybatis-plus下

1
2
3
4
5
6
7
8
9
10
11
12
13
#mybatis-plus 配置
mybatis-plus:
# 增加地址配置
mapper-locations: classpath:mapper/*Mapper.xml,mapper/*/*Mapper.xml
typeAliasesPackage: com.vbills.modules.entity
defaultStatementTimeout: 120
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
call-setters-on-nulls: true
global-config:
db-config:
logic-delete-value: 1 #删除
logic-not-delete-value: 0 #未删除

配完重启后就可以了,卧槽,尼玛用了mybatis-plus后,尼玛你大哥mybatis的配置你就不认了…好吧,哈哈哈;希望能帮到有缘人!

  • Title: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
  • Author: viEcho
  • Created at : 2021-06-27 12:23:52
  • Updated at : 2024-01-18 14:53:00
  • Link: https://viecho.github.io/2021/0627/mybatis-plus-binging-error.html
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)