2023-09-10
mybatis-plus中添加的依赖
<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.0</version> </dependency>
使用的方法
DeptDao
package com.hh.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hh.domain.Dept; import org.apache.ibatis.annotations.Mapper; /** * @author hh * @version 1.0 * @DATE 2023-09-10 17:36:59 */ @Mapper public interface DeptDao extends BaseMapper<Dept> { }
分页查询中添加的拦截器
MpConfig
package com.hh.config; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * @author hh * @version 1.0 * @DATE 2023-09-10 18:07:25 */ @Configuration public class MpConfig { @Bean public MybatisPlusInterceptor mpInterceptor(){ MybatisPlusInterceptor mp = new MybatisPlusInterceptor(); mp.addInnerInterceptor(new PaginationInnerInterceptor()); return mp; } }
TestDeptDao
@Test public void testPage(){ IPage page = new Page(1,2); deptDao.selectPage(page, null); System.out.println("当前页码值:"+page.getCurrent()); System.out.println("每页显示数:"+page.getSize()); System.out.println("一共多少页:"+page.getPages()); System.out.println("一共多少条数据:"+page.getTotal()); System.out.println("数据:"+page.getRecords()); }
标签:拦截器,System,添加,plus,println,import,com,page,out From: https://www.cnblogs.com/isDaHua/p/17691634.html