解決mybatis-plus3.4.1分頁插件PaginationInterceptor和防止全表更新與刪除插件SqlExplainInterceptor過時(shí)失效問題
前言
在Mybatis Plus 3.4.0版本之后PaginationInterceptor插件就失效,新增Mybatis Plus 3.4.0的新內(nèi)置插件
提示:以下是本篇文章正文內(nèi)容,下面案例可供參考
分頁插件
一、之前的配置
在sqlSessionFactoryBean中配置插件
<property name="plugins"> <array> <bean class="com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor"></bean> </array> </property>
二、Mybatis Plus 3.4.0版本之后配置分頁插件
在sqlSessionFactoryBean中配置插件
<property name="plugins"> <array> <!-- <bean class="com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor">--> <!-- </bean>--> <bean class="com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor"> <property name="interceptors"> <list> <bean class="com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor"></bean> </list> </property> </bean> </array> </property>
防止全表更新與刪除插件
一、之前的配置
在sqlSessionFactoryBean中配置插件
<property name="plugins"> <array> <bean class="com.baomidou.mybatisplus.extension.plugins.SqlExplainInterceptor"></bean> </array> </property>
二、Mybatis Plus 3.4.0版本之后配置防止全表更新與刪除插件
在sqlSessionFactoryBean中配置插件
<property name="plugins"> <array> <!-- <bean class="com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor">--> <!-- </bean>--> <!-- <bean class="com.baomidou.mybatisplus.extension.plugins.SqlExplainInterceptor"></bean>--> <bean class="com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor"> <property name="interceptors"> <list> <bean class="com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor"></bean> <bean class="com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor"></bean> </list> </property> </bean> </array> </property>
其中com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor
就是防止全表更新與刪除插件類
其他配置請(qǐng)參照官方文檔插件配置
ps:下面看下 Mybatis-plus新版本分頁失效,PaginationInterceptor過時(shí)問題
一、確認(rèn)mybatis-plus-boot-starter版本
3.4.0版本對(duì)此部分有更新,如果是舊版本升級(jí),會(huì)出現(xiàn)分頁失效問題,同時(shí)idea會(huì)提示PaginationInterceptor過時(shí),新版本改用了MybatisPlusInterceptor
二、Mybatis-plus3.4.0版本配置
更改新版配置后,分頁功能正常,注意DbType.MYSQL
改為自己使用的數(shù)據(jù)庫類型,否則分頁也不生效
@Configuration public class MyBatisPlusConfig { /* 舊版本配置 @Bean public PaginationInterceptor paginationInterceptor(){ return new PaginationInterceptor(); }*/ /** * 新的分頁插件,一緩和二緩遵循mybatis的規(guī)則,需要設(shè)置 MybatisConfiguration#useDeprecatedExecutor = false 避免緩存出現(xiàn)問題 */ @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); return interceptor; } @Bean public ConfigurationCustomizer configurationCustomizer() { return configuration -> configuration.setUseDeprecatedExecutor(false); } }
到此這篇關(guān)于解決mybatis-plus3.4.1分頁插件PaginationInterceptor和防止全表更新與刪除插件SqlExplainInterceptor過時(shí)失效問題的文章就介紹到這了,更多相關(guān)mybatis-plus3.4.1分頁插件內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Mybatis-Plus 多表聯(lián)查分頁的實(shí)現(xiàn)代碼
- Mybatis-plus新版本分頁失效PaginationInterceptor過時(shí)的問題
- MyBatis-Plus 分頁查詢以及自定義sql分頁的實(shí)現(xiàn)
- mybatis-plus分頁傳入?yún)?shù)后sql where條件沒有l(wèi)imit分頁信息操作
- mybatis-plus分頁查詢的實(shí)現(xiàn)示例
- MyBatis-Plus分頁插件不生效的解決方法
- MyBatis-Plus實(shí)現(xiàn)2種分頁方法(QueryWrapper查詢分頁和SQL查詢分頁)
- MyBatis-Plus分頁時(shí)排序的實(shí)現(xiàn)方法
- Mybatis-Plus中分頁插件PaginationInterceptor的使用
- 一文搞懂Mybatis-plus的分頁查詢操作
- MyBatis-Plus 分頁插件配置的兩種方式實(shí)現(xiàn)
相關(guān)文章
Java BufferedOutputStream類的常用方法講解
這篇文章主要介紹了Java BufferedOutputStream類的常用方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-10-10Mybatis的sql語句執(zhí)行異常后打印到日志問題
文章介紹了一種Mybatis異常日志打印方案,主要通過Mybatis攔截器獲取執(zhí)行的sql語句,并利用ThreadLocal存儲(chǔ),以避免多線程下的sql語句覆蓋問題,當(dāng)異常發(fā)生時(shí),從ThreadLocal中取出sql語句并打印到單獨(dú)的日志文件中,方便數(shù)據(jù)恢復(fù),該方案經(jīng)過壓力測試2024-10-10從java源碼分析線程池(池化技術(shù))的實(shí)現(xiàn)原理
這篇文章主要介紹了從java源碼分析線程池(池化技術(shù))的實(shí)現(xiàn)原理,池化技術(shù)是一種編程技巧,當(dāng)程序出現(xiàn)高并發(fā)時(shí),能夠明顯的優(yōu)化程序,降低系統(tǒng)頻繁創(chuàng)建銷毀連接等額外開銷,下文更多的相關(guān)介紹需要的小伙伴可以參考一下2022-04-04SpringBoot+Vue實(shí)現(xiàn)動(dòng)態(tài)菜單的思路梳理
這篇文章主要為大家詳細(xì)介紹了利用SpringBoot+Vue實(shí)現(xiàn)動(dòng)態(tài)菜單的思路梳理,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以動(dòng)手嘗試一下2022-07-07java基于mongodb實(shí)現(xiàn)分布式鎖的示例代碼
本文主要介紹了java基于mongodb實(shí)現(xiàn)分布式鎖,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08SpringBoot框架實(shí)現(xiàn)支付和轉(zhuǎn)賬功能
在 Spring Boot 框架中實(shí)現(xiàn)支付和轉(zhuǎn)賬功能時(shí),涉及到多個(gè)細(xì)節(jié)和注意點(diǎn),這些功能通常需要高度的安全性、穩(wěn)定性和可擴(kuò)展性,本文介紹了實(shí)現(xiàn)支付和轉(zhuǎn)賬功能的一些關(guān)鍵點(diǎn),需要的朋友可以參考下2024-08-08