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


  • 相关阅读:
    ambari
    linux常用命令
    scala新版本学习(3)
    Spring中的AOP
    Spring中的Bean
    Spring的基本应用(1):依赖以及控制反转
    Scala新版本学习(2):
    python之time模块
    python之编码与解码
    爬虫之re数据提取的使用
  • 原文地址:https://www.cnblogs.com/jerrys/p/11865371.html
Copyright © 2011-2022 走看看