spring boot mybatiscodehelper插件和pagehelper插件

1.idea搜索插件MybatisCodeHelper下载

需要激活码https://github.com/gejun123456/MyBatisCodeHelper-Pro

2.右下角插件添加表,选择mapperAnnotation,lombok,Serializable

3.添加方法,直接写方法名,然后全选,右键,generate mybatis xml,自动生成xml方法

具体方法看https://gejun123456.github.io/MyBatisCodeHelper-Pro/#/methodNameToSql

4.pagehelper插件引入

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.10</version>
</dependency>

5.使用,三个参数分别是第几页,每页几条数据和排序规则

public List<User> bbb(Integer minId,Integer maxId){
   PageHelper.startPage(2,5,"Id asc,Name desc");
   List<User> list = userMapper.findByIdGreaterThanEqualAndIdLessThanEqual(minId,maxId);
   return list;
}

6.在控制台显示sql语句,application.properties里写,com.mapper是你mapper接口所在的位置

mybatis.mapper-locations=classpath:/mapperxml/*Mapper.xml
mybatis.type-aliases-package=com.mapper

logging.level.com.mapper=debug

猜你喜欢

转载自blog.csdn.net/weixin_43245707/article/details/85013465