解决方法:
新建一个配置类,代码如下
@EnableTransactionManagement
@Configuration
public class MyBatisPlusConfig {
@Bean
public MybatisPlusInterceptor optimisticLockerInnerInterceptor(){
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return interceptor;
}
}