Mybatis-plus分页插件

集成mybatis-plus

         <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
        dependency>
        <dependency>
            <groupId>com.baomidougroupId>
            <artifactId>mybatis-plus-boot-starterartifactId>
            <version>3.4.3.4version>
        dependency>

配置文件

#数据库连接
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root

插件配置(此处不配置会影响分页)

@Configuration
@MapperScan("com.wy.es.es.mapper*")
public class MybatisPlusConfig {
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
        return interceptor;
    }
}

使用

 QueryWrapper<WcmmetatablezrzyCkqcfqk> qw = new QueryWrapper();
 //条件检索
 qw.eq("username",username)
 //页码和每页的大小
IPage<User> page = new Page(pageNum,pageSize);
IPage<User> result = userMapper.selectPage(page,qw);

问题

如果配置类中找不到类,请检查pom.xml的中mybatis-plus的版本!!!

你可能感兴趣的:(Mybatis,java,mysql,mybatis-plus)