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); }
测试结果: