邯城往事 邯城往事

>>> 展颜笑夙愿,一笑泯恩仇 <<<

目录
Springboot整合mybatis-plus分页
/  

Springboot整合mybatis-plus分页

  引入相关依赖

<dependency>
			<groupId>com.github.pagehelper</groupId>
			<artifactId>pagehelper-spring-boot-starter</artifactId>
			<version>1.2.3</version>
			<exclusions>
				<exclusion>
					<groupId>org.mybatis</groupId>
					<artifactId>mybatis</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.mybatis</groupId>
					<artifactId>mybatis-spring</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<!-- Mybatis-plus -->
		<dependency>
			<groupId>com.baomidou</groupId>
			<artifactId>mybatis-plus-boot-starter</artifactId>
			<version>3.1.0</version>
		</dependency>

  读取 mapper 路径

mybatis-plus :
  mapper-locations: classpath:mapper/*Mapper.xml
  type-aliases-package: com.jianwei

  在 mapper 类上声明此类是一个 mapper,也可以在 application 启动类上添加 mapperscan

@Mapper
public interface UploadFileMapper

  配置分页属性

pagehelper:
  helper-dialect : mysql
  reasonable : true
  support-methods-arguments : true
  pageSizeZero : true
  params : count=countSql

  使用分页

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

	PageHelper.startPage(pageNo, pageSize);
        List<UploadFile> list = uploadFileService.findList(new UploadFile());
        PageInfo pageInfo = new PageInfo<>(list);