我遇到的org.apache.ibatis.binding.BindingException问题是因为Mapper.java中接口和SQL的参数多于一个,Mybatis不知道如何一一对应,解决方法是加上@param注解,手动告诉MyBatis如何去对应。代码如下:

<?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.hy.mapper.SweepawayMapper">

     <select id="selectCleanExpiredParams" resultType="java.lang.String">
        select name||':'||value from Clean_Expired_Params order by sort
    </select>

    <select id="findTableExist"  resultType="integer">
        SELECT COUNT (*) as cnt FROM ALL_TABLES WHERE table_name = UPPER(#{tableName})
    </select>

    <select id="getAllExpiredCount"  resultType="integer">
        SELECT COUNT (*) as cnt from ${tableName} where created_datetime&lt;to_date(#{date},'yyyy-MM-dd')
    </select>

    <select id="getExpiredCount"  resultType="integer">
        SELECT COUNT (*) as cnt from ${tableName} where created_datetime&lt;to_date(#{date},'yyyy-MM-dd')  AND ROWNUM&lt;#{rowNum}
    </select>

    <delete id="sweepAwayExpired">
        delete from ${tableName} where created_datetime&lt;to_date(#{date},'yyyy-MM-dd') AND ROWNUM&lt;#{rowNum}
    </delete>  

</mapper>

而接口的写法是:

package com.hy.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;

@MyMapper
public interface SweepawayMapper {
    List<String> selectCleanExpiredParams();
    int findTableExist(String tableName);// 一个参数MyBati能认出来
    int getAllExpiredCount(@Param("tableName") String tableName,@Param("date") String date);// 多个参数得告诉MyBatis如何区分
    int getExpiredCount(@Param("tableName") String tableName,@Param("date") String date,@Param("rowNum") int rowNum);
    int sweepAwayExpired(@Param("tableName") String tableName,@Param("date") String date,@Param("rowNum") int rowNum);
}

--END-- 19/10/17 8:21

[MyBatis]org.apache.ibatis.binding.BindingException的避免的更多相关文章

  1. MyBatis—— org.apache.ibatis.binding.BindingException: Type interface com.web.mybatis.i.PersonMapper is not known to the MapperRegistry.

    报错信息: Exception in thread "main" org.apache.ibatis.binding.BindingException: Type interfac ...

  2. mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误

    最近在使用mybatis时,出现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 这 ...

  3. org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'username' not found. Available parameters are [1, 0, param1, param2]

    Spring+mybatis错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.bi ...

  4. 怪事年年有,今天特别多!org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'empno' not found. Available parameters are [emp, deptno, param1, param

    错误: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Binding ...

  5. MyBatis 传List参数 nested exception is org.apache.ibatis.binding.BindingException: Parameter 'idList' not found.

    在MyBatis传入List参数时,MyBatis报错:nested exception is org.apache.ibatis.binding.BindingException: Paramete ...

  6. SpringBoot整合Mybatis注解版---update出现org.apache.ibatis.binding.BindingException: Parameter 'XXX' not found. Available parameters are [arg1, arg0, param1, param2]

    SpringBoot整合Mybatis注解版---update时出现的问题 问题描述: 1.sql建表语句 DROP TABLE IF EXISTS `department`; CREATE TABL ...

  7. MyBatis笔记----报错Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectUser

    信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@41cf53f9: startup ...

  8. mybatis错误之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    玩了MyBatis差不多有两年了,中间也玩过MyBatis-Plus,这个MyBatis-Plus其实与MyBatis的区别并不大.今天写博客业务代码的时候,犯一个初学者犯过的错误. 错误信息如下:o ...

  9. Spring boot结合mybatis开发的报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found),经过排查确定是没有找到xml的原因 ...

随机推荐

  1. Elasticsearch 9300无法访问,客户端出现NoNodeAvailableException[None of the configured nodes are available:  [{#transport#‐1}{exvgJLR‐RlCNMJy‐hzKtnA}

    1.  进入容器 docker exec ‐it ID /bin/bash 2. 拷贝配置文件到宿主机 docker cp  ID:/usr/share/elasticsearch/config/el ...

  2. 查看python和NumPy版本和安装路径

    记录查看Python和NumPy版本以及路径的几条命令 # 查看Python版本及路径 python -V python -c "import sys;print(sys.executabl ...

  3. GPU显存释放

    一.当程序没有运行,但GPU仍被占用, 可通过nvidia-smi查看,被占用的pid是什么 或通过sudo fuser -v /dev/nvidia* #查找占用GPU资源的PID 然后采用kill ...

  4. ndk学习之C语言基础复习----结构体、共用体与C++开端

    自己实现sprintf功能: 关于C中的系统函数sprintf在上次[https://www.cnblogs.com/webor2006/p/7545627.html]学习中已经用到过了,这里再来回顾 ...

  5. windows下mysql5.6.x的日志正确配置方法(my.ini) (网上的都是5.6之前的版本)

    https://blog.csdn.net/databatman/article/details/49951853 感谢楼主,找了好久,试了一下楼主的,果然是对的,网上的日志配置都是5.6之前的版本: ...

  6. django--没有整理,笔记

    https://docs.djangoproject.com/en/2.2/常用的数据路命令:python manage.py makemigrations 数据移植准备python manage.p ...

  7. Codeforces Educational Codeforces Round 54 题解

    题目链接:https://codeforc.es/contest/1076 A. Minimizing the String 题意:给出一个字符串,最多删掉一个字母,输出操作后字典序最小的字符串. 题 ...

  8. 洛谷P1330 封锁阳光大学【dfs】

    题目:https://www.luogu.org/problemnew/show/P1330 题意:一个无向边,一个河蟹可以占领一个点,但一个点只能被一个河蟹占领. 占领了一个点之后,这个点所有的边都 ...

  9. 成熟度等级CMM

    软件能力成熟度模型 (Capability maturity model,CMM) CMM是目前国际上使用流行的一种软件生产过程行业标准模型,可定义.评价软件开发过程的成熟度,并提供提高软件质量的指导 ...

  10. 浅谈JavaScript严格模式(use strict)

    "use strict" 的目的是指定代码在严格条件下执行. 严格模式下你不能使用未声明的变量. 严格模式声明 严格模式通过在脚本或函数的头部添加 "use strict ...