码迷,mamicode.com
首页 > 移动开发 > 详细

奇葩问题:Invalid bound statement (not found): cn.zss.zsdemo.mapper.RoleMapper.selectByPrimaryKey

时间:2019-11-15 12:32:48      阅读:79      评论:0      收藏:0      [点我收藏+]

标签:方式   添加   entity   alt   img   span   log4j   names   sel   

使用mybatis,遇到Invalid bound statement (not found): cn.zss.zsdemo.mapper.RoleMapper.selectByPrimaryKey 这个问题,困扰了我好几天,在网上找了许多方法使用没有解决。

这个问题不好查,会报这个错的原因太多了,网友整理的查找原因方法如下:

1、检查mapper.xml文件中<mapper namespace="xxxMapper"> 标签是否指向了正确的mapper接口;

   我的是正确的
2、检查是否正确显式指定mapper接口所在位置

      方式一:启动类上添加注解@MapperScan(“com.xxs.shirodemo.dao”)

      方式二:在每一个mapper接口上添加注解@Mapper

3、检查mapper.xml的配置路径是否正确

           mybatis:
                mapper-locations: classpath*:mapping/*.xml

4、检查mapper接口中的方法名与mapper.xml中操作的id是否相同、是否有一方缺少。

我的问题就出在第3条,我把mybaits配置放在了spring:  下,其实要单独拉出来与spring并列

如图

技术图片
spring:
  datasource:
       ……
  freemarker:
       ……

mybatis:
      mapper-locations: classpath*:mapper/*.xml
      type-aliases-package: cn.zss.zsdemo.entity

#log4j2
logging:
   config: classpath:log4j2.xml
View Code

 



奇葩问题:Invalid bound statement (not found): cn.zss.zsdemo.mapper.RoleMapper.selectByPrimaryKey

标签:方式   添加   entity   alt   img   span   log4j   names   sel   

原文地址:https://www.cnblogs.com/jerrys/p/11865371.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!