zoukankan      html  css  js  c++  java
  • 奇葩问题:Invalid bound statement (not found): cn.zss.zsdemo.mapper.RoleMapper.selectByPrimaryKey

    使用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


  • 相关阅读:
    字典树+二叉树
    ##22
    简单代码优雅写
    全排列
    【持续更新】哟!又在写BUG啊!
    大整数加法和大整数乘法
    【框架编程思想】线数筛的高级应用(欧拉12题和欧拉21题)
    【持续更新】 用算法流程实现的代码块们
    记忆化
    资源收集
  • 原文地址:https://www.cnblogs.com/jerrys/p/11865371.html
Copyright © 2011-2022 走看看