不能和邏輯刪除一起配置,不然報錯。
邏輯刪除的配置:
????@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
2019-11-26
不能同時制定兩個sql注入器,所以報錯,你有一個辦法MySqlinjector不要繼承DefaultSqlInjector直接繼承LogicSqlInjector就可以了,你就配置這一個sql注入器,就既能使用邏輯刪除又能加入自定義方法了。
2019-11-26
知道了。老師你講的這個自定義通用方法沒有參數,如果有參數怎么辦,比如 myDeledeById(int id)