慕粉1469371404
2019-11-26 15:54
逻辑删除的配置:
@Bean
public ISqlInjector sqlInjector(){
return new LogicSqlInjector();
}mySqlInjector的配置:
@Component
public class MySqlinjector extends DefaultSqlInjector {
@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
//调用super的方法,否则mybatisplus的默认方法都不能用
List<AbstractMethod> methodList = super.getMethodList(mapperClass);
//加入自定义的方法
methodList.add(new RemoveById());
return methodList;
}
}报错:
No qualifying bean of type 'com.baomidou.mybatisplus.core.injector.ISqlInjector' available: expected single matching bean but found 2: mySqlinjector,sqlInjector
不能同时制定两个sql注入器,所以报错,你有一个办法MySqlinjector不要继承DefaultSqlInjector直接继承LogicSqlInjector就可以了,你就配置这一个sql注入器,就既能使用逻辑删除又能加入自定义方法了。
知道了。老师你讲的这个自定义通用方法没有参数,如果有参数怎么办,比如 myDeledeById(int id)
MyBatis-Plus进阶
23494 学习 · 118 问题
相似问题