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

天行健,君子以自强不息;地势坤,君子以厚德载物。


每个人都有惰性,但不断学习是好好生活的根本,共勉!


文章均为学习整理笔记,分享记录为主,如有错误请指正,共同学习进步。

Bug笔记0008

  • 描述
  • 报错
  • 分析
  • 解决

描述

使用postman调用接口新增数据到mysql时报错

报错

postman报错

{
    "timestamp": "2023-08-27T12:54:52.394+00:00",
    "status": 500,
    "error": "Internal Server Error",
    "path": "/user/register"
}

截图
nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):_第1张图片

控制台报错

2023-08-27 20:54:52.394 ERROR 22100 --- [nio-8888-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.libai.user.service.TbUserInfoMapper.insert] with root cause

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.libai.user.service.TbUserInfoMapper.insert
	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235) ~[mybatis-3.5.9.jar:3.5.9]
.......
中间省略N......
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at java.lang.Thread.run(Thread.java:750) [na:1.8.0_371]

截图
nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):_第2张图片

分析

翻译报错如下
在这里插入图片描述
大概就是因为映射文件和接口绑定失败引起请求失败
仔细查看发现接口文件TbUserInfoMapper.java和TbUserInfoMapper.xml两个文件不在同一个包内
nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):_第3张图片
生成的时候将他俩分别放在了两个包中,此时系统扫包时只发现一个文件,所以导致报错

解决

将两个文件放在一个包内即可
nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):_第4张图片
修改后重启项目,执行请求,可用

感谢阅读,祝君暴富!


你可能感兴趣的:(BaseAndView,bug,java)