在MybatisPlusConfig中,注册乐观锁插件时报错:Cannot resolve symbol ‘MybatisPlusInterceptor’
在pom.xml中检查依赖,发现mybatis-plus-boot-starter安装的是3.0.5,改成更高版本的就可以了,我的是改成了3.4.3.1,更改完后刷新一下maven即可。
com.baomidou mybatis-plus-boot-starter 3.4.3.1
另外附上乐观锁插件代码
spring.xml方式springboot方式
// Spring Boot 方式
@Configuration
@MapperScan("按需修改")
public class MybatisPlusConfig {
@Bean
public OptimisticLockerInterceptor optimisticLockerInterceptor() {
return new OptimisticLockerInterceptor();
}
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return mybatisPlusInterceptor;
}
}



