Invalid bound statement (not found)解决

Invalid bound statement (not found)

最近项目开发的时候遇到一个很阴间的问题:
在这里插入图片描述
该问题是因为mapping下有一个文件夹的mapper.xml文件无法读取到。如图:
在这里插入图片描述
而application.yml、mapper层也完全没问题,
application.yml

mybatis-plus:
  mapper-locations: classpath*:mapping/**/*.xml
  #实体扫描,多个package用逗号或者分号分隔
  typeAliasesPackage: com.aisino.entity
  global-config:
    #主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
    id-type: 0
    #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
    field-strategy: 2
    #驼峰下划线转换
    db-column-underline: true
    #刷新mapper 调试神器
    refresh-mapper: true
    #数据库大写下划线转换
    #capital-mode: true
    # Sequence序列接口实现类配置
    #key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
    #逻辑删除配置
    logic-delete-value: -1
    logic-not-delete-value: 0
    #自定义填充策略接口实现
    #meta-object-handler: com.baomidou.springboot.xxx
    #自定义SQL注入器
    sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
  configuration:
    map-underscore-to-camel-case: true
    cache-enabled: false
    call-setters-on-nulls: true
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

BmLabelMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.aisino.mapper.mapper3.BmLabelMapper">

    <select id="selectAllEmployee" resultType="com.aisino.entity.EmployeeInfoEntity">
        select * from CWXXH_EMPLOYEE
    </select>

</mapper>

BmLabelMapper.java

package com.aisino.mapper.mapper3;

import com.aisino.entity.EmployeeInfoEntity;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @Classname queryLabelMapper
 * @Description TODO
 * @Date 2021/1/18 9:27
 * @Created by fly
 */
public interface BmLabelMapper {

    /**
     * 查询所有员工
     *
     * @return List<EmployeeInfoEntity>
     */
    List<EmployeeInfoEntity> selectAllEmployee();
}

在pom.xml文件中也配置了mapper的检测路径
在这里插入图片描述

因为是将别人的springboot项目对接进微服务平台,而该项目springboot版本比较老,且springcloud是Edgware.RELEASE版本。该版本不支持openfeign进行服务调用,因此我们将其springboot版本进行了升级。升级之后该项目用到mapper3文件的一个定时任务出现了如上问题,而该项目在springboot未进行升级时能够正常运行。经过初步问题定位,我们决定想办法解决maven依赖冲突,将该项目的其他依赖都升级到新配置的springboot支持的版本,结果仍然没有解决。因此我们转变方向开始思考该项目的数据源的配置方式,终于找出了问题所在。
该项目有三个数据源,分别使用@Configuration和@MapperScan进行了配置。而它进行MybatisPlusConfig配置时,也使用了@MapperScan,最后SpringbootApplication上也加了@MapperScan,直接造成了配置覆盖,因此去掉该两处的@MapperScan之后再运行,运行成功。
总结原因,应该是之前项目进行开发的时候就存在开发问题,但是当时springboot相关配置版本过低,对于该问题的要求不严格,而在升级到较新版本之后,就已经不支持该配置方式,因此出现了该问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值