当前使用版本(必填,否则不予处理)
3.5.2
该问题是如何引起的?(确定最新版也有问题再提!!!)
一个bean注入命名的问题,建议官方文档修改样例。不要用mybatisPlusInterceptor做样例
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 乐观锁注册
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
// 防全表删与更新
interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
return interceptor;
}
使用这种方式死活注入不进去,改成如下就好使了
@Bean
public MybatisPlusInterceptor customMybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 乐观锁注册
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
// 防全表删与更新
interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
return interceptor;
}
重现步骤(如果有就写完整)
报错信息
Comment From: shijiebei2009
原因是依赖的一个底层库,用mybatisPlusInterceptor注册过了,导致再次注入失败