mybatis 异常处理:Invalid bound statement (not found)

mybatis 的使用过程中提示错误: 
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.msunsoft.mapper.HisLisReportMapper.getMaxMtcData

含义:HisLisReportMapper的getMtcData方法没有找到或者没有绑定

背景: 
1.HisLisReportSyncWorker 控制类中

String hospitalCode = ConfigRead.getValue("config.properties",
                    "HOSPITAL_CODE");
            List<Integer> updateIdList = new ArrayList<>();
            HisLisReportService hisLisReportService = (HisLisReportService) DataVisitorHolder
                    .getVisitorMap().get("hisLisReportService");
            HashMap<Object, Object> maxHisLisReportMap = hisLisReportService
                    .getMaxMtcData(hospitalCode);
            HashMap<Object, Object> map = hisLisReportService
                    .getMaxChangeVersion(hospitalCode);

HisLisReportServiceImpl

@Override
    @DataSource(name="blSql35")
    public HashMap<Object, Object> getMaxChangeVersion(String hospitalCode)
            throws Exception {
        // TODO Auto-generated method stub
        return hisLisReportMapper.getMaxChangeVersion(hospitalCode);
    }

HisLisReportMapper 代码

@Override
    public HashMap<Object, Object> getMaxChangeVersion(String hospitalCode)
            throws Exception ;

HisLisReportService 代码

@Override
    public HashMap<Object, Object> getMaxChangeVersion(String hospitalCode)
            throws Exception ;

Mybatis.xml文件

 <select id="getMaxChangeVersion" parameterType="java.lang.String" resultType="java.util.HashMap">
        select
        max(sys_change_version) as MAXVERSION ,max(etl_id) as MAXID from
        ETL.DBO.ETL_CHARGE_RECORD where hospital_code=#{hospitalCode} and etl_table=‘lismain.lisdata.report_main‘
    </select>

      <select id="getMaxMtcData" parameterType="java.lang.String" resultType="java.util.HashMap">
        select max(his_lis_report_id) as MAXID from his_lis_report where hospital_code=#{hospital_code}
     </select>

错误处理流程: 
我这里使用的SSM,spingMvc ,mybatis ,maven来构建项目,项目中使用了HisLisReportSyncWorker的控制类,HisLisReportServiceImpl代码实现,HisLisReportService接口类,HisLisReportMapper 的mapper类以及HisLisReportMapper.xml配置文件

1.检查实现类中方法是否存在

2。检查Service类的这个方法是否存在

3.检查Mapper类的这个方法

4.对应的mybatis 的配置文件是否存在,里面数据是否配置正确

5.检查Mapper类是否被加载了

这个错误主要是因为在config的配置文件中没有加载这个xml文件

时间: 2024-07-29 16:26:52

mybatis 异常处理:Invalid bound statement (not found)的相关文章

mybatis中Invalid bound statement (not found) 和 Result Maps collection already contains value for...错误解决方案

一.Invalid bound statement (not found) 使用mybatis有时候会报Invalid bound statement (not found)这种错误,总结了下,可能有两种情况如下: 1.mybatis的对应的mapper.xml找不到对应的命名sql或者名称与mapper接口名称不一致. 2.xml文件与接口名称都对,但是在mybatis配置文件中漏掉了配置,也会报这种错误. 二.Result Maps collection already contains v

解决Mybatis的invalid bound statement (not found)异常

使用Maven构建SSM时, 需要在pom.xml中配置一些信息, 否则mapper.xml就无法被扫描到, 程序就会抛invalid bound statement (not found)异常 解决办法: 将下面配置添加到pom.xml文件中 1 <build> 2 <resources> 3 <resource> 4 <directory>src/main/java</directory> 5 <includes> 6 <i

mybatis的Invalid bound statement (not found)

报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 解释:就是说,你的Mapper接口,被Spring注入后,却无法正常的使用mapper.xml的sql: 这里的Spring注入后的意思是,你的接口已经成功的被扫描到,但是当Spring尝试注入一个代理(MyBatista实现)的实现类后,却无法正常使用.这里的可能发生的情况有如下几种: 接口已经被扫描到,但是代理对象没有找到,即使

关于 Mybatis 的Invalid bound statement (not found):错误

今天遇到一个特别奇怪的问题,最后发现是自己对mybatis的学习还有待提高 返回类型可以用resultType,也可以用resultMap resultType是直接表示返回类型的,而resultMap则是对外部ResultMap的引用 举个例子: resultMap: <select id="findByContract" resultMap="BaseResultMap">        select        *        from    

idea的spring整合基于xml文件配置的mybatis报Invalid bound statement (not found): com.music.dao.MusicDao.findAll的问题

一. 题主当时就是自己尝试整合spring和mybatis的时候遇到了这个问题,当时题主只看到了用注解的方式配置的dao层,题主用的是xml文件配置的形式, 而且坑爹的是题主的两个文件的路径写的也不一致,就导致直接用<property name="basePackage" value="com.music.dao"></property> 导致绑定异常 后来在网上查到了解决的办法 ,就是如果路径一致,(如果一致你也就不会来看到本文了), 两个

mybatis plus Invalid bound statement (not found) 解决方案

常规的解决方案见:https://www.cnblogs.com/shaoyu/p/11477125.html 问题:当xml文件在src/main/java目录下时,在application.yml中配置Mapper文件路径无效,当xml文件在resource下时路径有效,原因不明. 我通过上面连接提到的所有的方法都无法解决遇到的问题.可能是mybatis plus的特殊性造成的,在参考其他人的解决方案的情况下, 终于解决了这个问题,解决方案如下: 重新在SqlSessionFactory中指

关于mybatis Invalid bound statement (not found) 问题

初学mybatis   现在系统是spring + mybatis  applicationContext.xml里面配置了Mapper 自动扫描 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">    <property name="basePackage" value="com.yolly.platform.*" /></bean&g

转载:Maven项目mybatis Invalid bound statement (not found)解决方法

在mapper代理的开发中,程序员需要遵守一些规范,mybatis才能实现mapper接口的代理对象. 它的规范如下: mapper.xml的namespace要写所映射接口的全称类名. mapper.xml中的每个statement的id要和接口方法的方法名相同 mapper.xml中定义的每个sql的parameterType要和接口方法的形参类型相同 mapper.xml中定义的每个sql的resultType要和接口方法的返回值的类型相同 mapper.xml要和对应的mapper接口在

Mybatis 异常记录(1): Invalid bound statement (not found)

错误信息: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.pingan.credit.dao.mapper.TdReportMapper.insertQueryLog at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:223) at org.apache.ibatis