配置mybatis-plus时出错 ‘MP_OPTLOCK_VERSION_ORIGINAL’ not found,下面这个配置是老版本乐观锁配置方法
@Bean
public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor(){
return new OptimisticLockerInnerInterceptor();
}
官方文档给出乐观锁最新配置方法:
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return interceptor;
}
此外,除mybatis-版本问题外,出现Parameter ‘MP_OPTLOCK_VERSION_ORIGINAL’ not found 的另一个原因是配置类中要加@Configuration注解,以及实体类中也要加上注解
@Version
private Integer version;
`