{"id":37024680,"url":"https://github.com/smallcham/mybatis-page","last_synced_at":"2026-01-14T02:59:30.077Z","repository":{"id":52638278,"uuid":"75264401","full_name":"smallcham/mybatis-page","owner":"smallcham","description":"Mybatis分页插件","archived":false,"fork":false,"pushed_at":"2021-04-22T17:44:29.000Z","size":31,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-20T21:06:09.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smallcham.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-01T06:52:46.000Z","updated_at":"2020-11-13T11:11:53.000Z","dependencies_parsed_at":"2022-08-21T10:10:45.379Z","dependency_job_id":null,"html_url":"https://github.com/smallcham/mybatis-page","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/smallcham/mybatis-page","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallcham%2Fmybatis-page","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallcham%2Fmybatis-page/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallcham%2Fmybatis-page/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallcham%2Fmybatis-page/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smallcham","download_url":"https://codeload.github.com/smallcham/mybatis-page/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallcham%2Fmybatis-page/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T02:59:28.626Z","updated_at":"2026-01-14T02:59:30.063Z","avatar_url":"https://github.com/smallcham.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"#mybatis-page\n\n##说明\n- 无需`count`，自动实现分页并返回分页信息，使用方法简单\n- 可能是使用起来最方便的分页插件\n- 包含了`mybatis-3.4.1` `mybatis-spring-1.3.0`不需要重复引入\n\n###插件目前支持以下数据库\n- `Mysql`\n- `Oracle`\n\n###配置方法\n####Maven依赖\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.smallcham\u003c/groupId\u003e\n    \u003cartifactId\u003emybatis-page-nodep\u003c/artifactId\u003e\n    \u003cversion\u003e1.5-RELEASES\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n####mybatis.xml配置文件, 在`configuration`标签内添加\n```xml\n\u003cplugins\u003e\n    \u003cplugin interceptor=\"com.github.smallcham.plugin.page.interceptor.FastPage\"\u003e\n    \t\u003c!-- 数据库类型（必须配至） --\u003e\n\t\t\u003cproperty name=\"type\" value=\"MYSQL\"/\u003e\n\t\t\u003c!-- 需要拦截的分页方法正则（必须配置） --\u003e\n\t\t\u003cproperty name=\"method\" value=\".*query*;.*page*\"/\u003e\n\t\t\u003c!-- 每页显示多少条（可选配置） --\u003e\n\t\t\u003cproperty name=\"size\" value=\"50\"/\u003e\n\t\u003c/plugin\u003e\n\u003c/plugins\u003e\n```\n\u003cb\u003e注：\u003c/b\u003e\n- 数据库类型不区分大小写\n- 每页显示多少条可以在代码中传参配置，也可以在xml文件中配置，如果都没有配则默认一页显示10条（`优先级从高到低为 代码配置 -\u003e xml配置-\u003e 默认配置`）即：如果代码中配置了size，则其它配置无效\n\n###使用方法示例\nproductMapper接口\n```js\nList\u003cObject\u003e query(RowBounds rowBounds);\n```\n\nproductService实现\n```js\npublic Page\u003cProduct\u003e query(Product product, int nowPage) {\n    //nowPage为要查询的页数\n    RowBounds rowBounds = Page.rowBounds(nowPage, product);\n    List\u003cProduct\u003e products = productMapper.query(rowBounds);\n    return Page.asPage(rowBounds, products);\n}\n```\n\u003cb\u003e注：`Page.rowBounds(nowPage, product)`支持`pageSize`参数, 即 `Page.rowBounds(nowPage, pageSize, product)`\u003c/b\u003e\n\nproductMapper.xml SQL编写\n```xml\n\u003cselect id=\"query\" resultMap=\"BaseResultMap\" parameterType=\"com.github.smallcham.plugin.page.support.RowBounds\"\u003e\nSELECT\n\u003cinclude refid=\"Query_Column_List\" /\u003e\nFROM product p, product_type pt\n\u003cwhere\u003e\n  \u003cif test=\"null != v.productCode and '' != v.productCode\"\u003e\n    AND p.product_code = #{v.productCode}\n  \u003c/if\u003e\n  \u003cif test=\"null != v.productName and '' != v.productName\"\u003e\n    AND p.product_name = #{v.productName}\n  \u003c/if\u003e\n  \u003cif test=\"null != v.productTypeCode and '' != v.productTypeCode\"\u003e\n    AND p.product_type_code = #{v.productTypeCode}\n  \u003c/if\u003e\n  \u003cif test=\"null != v.productState and '' != v.productState\"\u003e\n    AND p.product_state = #{v.productState}\n  \u003c/if\u003e\n  AND p.product_type_code = pt.product_type_code\n\u003c/where\u003e\n\u003c/select\u003e\n```\n\u003cb\u003e需要注意的是，sql中的查询参数使用都需要在前面加`v.` 如：`#{v.productName}`，这是因为RowBounds对象中封装了传入的参数对象\u003c/b\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallcham%2Fmybatis-page","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmallcham%2Fmybatis-page","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallcham%2Fmybatis-page/lists"}