MyBatisPlus高版本的一些改动

MyBatisPlus高版本的一些改动(3.4.2)

MyBatisPlus的SelectMapsPage (Page类型不一致报错)

旧版本写法,会报错

  //测试selectMapsPage分页:结果集是Map
 

    @Test
    public void testSelectMapsPage(){
    
    
        Page<User> page = new Page<>(2,3);
        userMapper.selectMapsPage(page, null)
        page.getRecords().forEach(System.out::println);
    }
'selectMapsPage(E, com.baomidou.mybatisplus.core.conditions.Wrapper<com.example.entity.User>)' in 'com.baomidou.mybatisplus.core.mapper.BaseMapper' cannot be applied to '(com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.example.entity.User>, null)'

新版本写法,我的mybatis是3.4.2

  @Test
    public void selectMapsPage() {
    
    

        IPage<Map<String, Object>> page = new Page<>(2, 3);
        userMapper.selectMapsPage(page, null);
        page.getRecords().forEach(System.out::println);
    }

逻辑删除插件报错

在这里插入图片描述
这是因为mybatisplus高版本导致的(我的是3.4.2),高版本以及不需要注册逻辑删除的插件了,只需要逻辑删除的字段上增加@TableLogic注解就表示逻辑删除
@TableLogic(value=“原值”,delval=“修改值”)
注解参数
    value = “” 未删除的值,默认值为0
    delval = “” 删除后的值,默认值为1

其它插件改动

像分页插件,乐观锁插件

//分页插件
@Bean
public PaginationInterceptor paginationInterceptor() {
    
    
    return new PaginationInterceptor();
}

都是改成这种添加方式

    //分页插件
    @Bean
    public MybatisPlusInterceptor paginationInnerInterceptor(){
    
    
        MybatisPlusInterceptor paginationInnerInterceptor = new MybatisPlusInterceptor();
        paginationInnerInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return paginationInnerInterceptor;

    }

猜你喜欢

转载自blog.csdn.net/isis45454545454/article/details/126803782