SpringBoot整合MP过程中报错
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.wjx.demo3_admin.Mapper.EmpMapper.deleteById
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235) ~[mybatis-3.5.9.jar:3.5.9]
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:50) ~[mybatis-plus-core-3.5.1.jar:3.5.1]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda$cachedInvoker$0(MybatisMapperProxy.java:111) ~[mybatis-plus-core-3.5.1.jar:3.5.1]
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_301]
at com.baomidou.mybatisplus.core.toolkit.CollectionUtils.computeIfAbsent(CollectionUtils.java:115) ~[mybatis-plus-core-3.5.1.jar:3.5.1]
...
原因:MP的deleteById根据主键进行删除,如果没有在实体类中用注解@TableId标注主键字段,那么该字段的名称必须为 id
解决1:实体类主键添加@TableId注解
@TableId
private int eid;
解决2:实体类主键字段改名为 id
private int id;
在SpringBoot应用中整合MyBatis-Plus(MP)时遇到一个异常,具体表现为`org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)`,原因是实体类未正确标注主键字段。解决方法有两种:一是在实体类中使用@TableId注解明确主键;二是将主键字段名改为'id'。遵循这些步骤,可以避免MyBatis-Plus在尝试执行deleteById操作时找不到对应的SQL语句。
1万+

被折叠的 条评论
为什么被折叠?



