mybatis-plus具有mybatis的所有功能,又多出一部分增强功能。
首先pom:
<!-- mybatisPlus 核心库 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.3.1</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> <version>3.3.1</version> </dependency> <!--<!– 模板引擎 –>--> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-engine-core</artifactId> <version>2.2</version> </dependency>
然后配置类:
package net.ylxt.sites.config; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * mybatis-plus分页插件配置类 * * @author zel * @date 2020/2/17 18:57 */ @Configuration public class MybatisPlusConfig { /** * mybatis-plus分页插件 */ @Bean public PaginationInterceptor paginationInterceptor() { PaginationInterceptor page = new PaginationInterceptor(); // 设置方言 page.setDialectType("mysql"); return page; } }
后端分页数据获取:
Page<UserMoneyLog> pu = iUserMoneyLogService.page(new Page<UserMoneyLog>(Integer.parseInt(currPage), Integer.parseInt(pageSize)), new QueryWrapper<UserMoneyLog>()); res.put("pageUtil",pu);