解决mybatis-plus新版SqlExplainInterceptor过时,配置防止全表更新与删除插件

springboot:

@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
   MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

   List<InnerInterceptor> list = new ArrayList<>();
   list.add(new BlockAttackInnerInterceptor());
   interceptor.setInterceptors(list);

   return interceptor;
}

配置文件:

<property name="plugins">
   <array>
    <bean class="com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor">
     <property name="interceptors">
      <list>
       <bean class="com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor">bean>
      list>
     property>
    bean>
   array>
property>

测试全表更新:

@Test
public void testUpdateAll(){
   User user = new User();
   user.setAge(18);  //全表更新数据

   boolean result = user.update(null);
   System.out.println("result==>"+result);
}

测试结果:
在这里插入图片描述
测试单条记录更新:

@Test
public void testUpdate(){
    User user = new User();
    user.setId(6L);
    user.setAge(8);
    user.setEmail("[email protected]");
    boolean result = user.updateById();
    System.out.println("result==>"+result);
}

测试结果:
解决mybatis-plus新版SqlExplainInterceptor过时,配置防止全表更新与删除插件_第1张图片

你可能感兴趣的:(MybatisPlus)