添加依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.0</version>
</dependency>
在启动类编辑
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
return interceptor;
}
Mapper层编写
IPage<User> getList(Page<Object> page);
xml文件编写SQL
<select id="getList" resultMap="getUserDate">
select * from user
<!-- select * from user 最后不能添加;号-->
</select>
Test测试
@Test
void Test01(){
Page<Object> page = new Page<>(0, 2);
List<User> records = userMapper.getList(page).getRecords();
records.forEach(item->System.out.println(item));
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。