Solon

mybatis-pagehelper-solon-plugin

<dependency>
    <groupId>org.noear</groupId>
    <artifactId>mybatis-pagehelper-solon-plugin</artifactId>
</dependency>

1、描述

数据扩展插件,为 mybatis-solon-plguin 插件提供分页支持。

2、配置示例

solon.app:
    name: demoapp
    group: demo

demo.db1:
    schema: rock
    jdbcUrl: jdbc:mysql://localhost:3306/rock?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=true
    driverClassName: com.mysql.cj.jdbc.Driver
    username: root
    password: 123456

#映射配置
mybatis.db1:
    typeAliases:    #支持包名 或 类名(.class 结尾)
        - "demo.model"
    mappers:        #支持包名 或 类名(.class 结尾)或 xml(.xml结尾)
        - "demo.dso.mapper"


#分页组件的配置
pagehelper:
    offsetAsPageNum: true
    rowBoundsWithCount: true
    pageSizeZero: true
    reasonable: false
    params: pageNum=pageHelperStart;pageSize=pageHelperRows;
    supportMethodsArguments: false

3、应用示例

//启动应用
public class DemoApp {
    public static void main(String[] args) {
        Solon.start(DemoApp.class, args;
    }
}

//配置数据源
@Configuration
public class Config {
    @Bean
    public DataSource db1(@Inject("${demo.db1}") HikariDataSource ds) {
        return ds;
    }
}

//应用
@Service
public class AppService{
    @Db
    AppMapper appMapper; 
    
    public Object test(){
        PageHelper.offsetPage(2, 2);
        return appxMapper.appx_get_page();
    }
}

具体可参考:

https://gitee.com/noear/solon-examples/tree/main/4.Solon-Data/demo4023-mybatis_pagehelper