栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Spring Boot整合Mybatis时报错:无效的绑定语句(未找到):com.xxxx.springbootmybatis.mapper.Userxmlmapper.selcetAll

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Spring Boot整合Mybatis时报错:无效的绑定语句(未找到):com.xxxx.springbootmybatis.mapper.Userxmlmapper.selcetAll

本次使用的Springboot来整合Mybatis去调用数据库进行操作,发现按照以往的Mybatis常规操作,遇到了一些问题。

在使用注解时,能够完美运行。

在使用xml时,按照以往的com.xxx.mapper进行接口和xml的书写发现出现了问题。

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rachel.springbootmybatis.mapper.Userxmlmapper.selectAll

首先在Target目录下进行了排查

发现xml文件是存在的。

另外又对mapper常出的问题进行了排查,具体如下:

  1.  Mapper.接口名称和Mapper.xml是否一致
  2. Mapper接口中的方法是否在Mapper.xml中均被实现
  3. Mapper.xml中的namespace是否为Mapper接口的应用路径
  4. application.propertis或application.yml配置mybatis.type-aliases-package配置实体路径是否正确
  5. application.propertis或application.yml配置mybatis.mapper-locations是否正确
  6. springboot入口程序中是否有添加@MapperScan(“com.xx.xx.xx.xx.dao.mapper”)注解,路径是否到mapper的包名

发现均没有问题,再看yaml文件的配置

#datasoure
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/springboot
    username: root
    password: 527113
    driver-class-name: com.mysql.cj.jdbc.Driver


#mybatis
mybatis:
  #mapper映射

  mapper-locations: classpath:mapper*.xml
               
               false
           

问题得到解决。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1010009.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号