JAVA全系列 教程
3762个小节阅读:7094.2k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
在配置类或启动类配置分页插件:
xxxxxxxxxx
// 注册插件
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
作用:分析删除/更新语句,防止小白或者恶意进行删除/更新全表操作。
注意:
- 该插件只支持 MySQL5.6.3 以上版本
- 该插件只建议在开发环境中使用,不建议在生产环境使用
插件使用:
在配置类或启动类配置防止全表更新与删除插件
xxxxxxxxxx
// 注册插件
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 分页插件
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
// 防止全表更新与删除插件
interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
return interceptor;
}
测试全表删除
xxxxxxxxxx
// AR删除所有
@Test
public void testDeleteAll() {
Student student = new Student();
student.delete(new QueryWrapper());
}
1. 在MyBatisPlus中,分页插件是类
A InnerInterceptor
B PaginationInnerInterceptor
C BlockAttackInnerInterceptor
D OptimisticLockerInnerInterceptor
2. 在MyBatisPlus中,防止全表更新与删除插件是类
A InnerInterceptor
B PaginationInnerInterceptor
C BlockAttackInnerInterceptor
D OptimisticLockerInnerInterceptor
1=>B 2=>C