SpringBoot之Mybatis开启SQL记录和Pagehelper
配置mybatis
mybatis:
#mapper路径 mapper-locations: classpath:mapper/*.xml configuration:
#日志输出 log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启驼峰命名 map-underscore-to-camel-case: true
分页配置
pagehelper: helper-dialect: mysql #数据库,不指定默认自动检测数据库 reasonable: true #是否启动分页合理化 support-methods-arguments: true #默认为 false,分页插件会从查询方法的参数值中,自动根据上面 params 配置的字段中取值,查找到合适的值时就会自动分页。 params: count=countSql #从对象中根据属性名取值,可以配置 pageNum,pageSize,count,pageSizeZero,reasonable,默认值 pageNum=pageNum;pageSize=pageSize;count=countSql;reasonable=reasonable
分页插件 pagehelper依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
使用分页
// 设置第几条记录开始,多少页记录为一页 PageHelper.startPage(1,5); List list=mapper.findAll(); PageInfo<User> pageInfo = new PageInfo<>(list);
浙公网安备 33010602011771号