# springboot-mybatis-interceptor **Repository Path**: gapper/springboot-mybatis-interceptor ## Basic Information - **Project Name**: springboot-mybatis-interceptor - **Description**: springboot环境下如何定义mybatis的拦截器 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 2 - **Created**: 2020-07-23 - **Last Updated**: 2022-01-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 1. 该例子首先搭建了springboot-ssm环境 2. 在springboot-ssm环境的基础之上,演示了如何创建一个mybatis的拦截器 3. 注意,在application.yml中开启了显示sql语句的日志 4. 不使用page-helper时,RowBounds是一个软分页,即查出数据库中的结果,然后在内存中分页 5. 使用的数据库是filmclub ==================================================================== 步骤: 1. 创建一个类,实现org.apache.ibatis.plugin.interceptor接口 2. 在该类上添加注解: @Intercepts({@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})}) 该注解表示拦截指定类的指定方法,在Mybatis中只能拦截4个固定的方法 3. 在该类上添加一个@Component注解,完。 4. 最后加上了pagehelper分页插件,注意,4.1.6版本运行起来完全没有错误, 但是换到5.1.11版本,就会有问题。 具体原因可以去pagehelper官网中的“规范”查看。