OptimisticLockerInterceptor 在新版本的MP中已弃用,但仍然能用,下边是两种注册方式:
@Configuration
@MapperScan("com.xxx.xxx.mapper")
public class MpConfig {
// 注册乐观锁插件(新版:3.4.0)
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return mybatisPlusInterceptor;
}
// 乐观锁插件
@Bean
public OptimisticLockerInterceptor optimisticLockerInterceptor () {
return new OptimisticLockerInterceptor();
}
}
我是小白