Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zoeminghong/spring-boot-starter-mybatis
mybatis的spring boot分页插件
https://github.com/zoeminghong/spring-boot-starter-mybatis
mybatis mybatis-page mybatis-spring-boot-starter mybatis-springboot page spring spring-boot
Last synced: about 2 months ago
JSON representation
mybatis的spring boot分页插件
- Host: GitHub
- URL: https://github.com/zoeminghong/spring-boot-starter-mybatis
- Owner: zoeminghong
- License: apache-2.0
- Created: 2018-02-01T04:27:45.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-18T06:19:04.000Z (over 6 years ago)
- Last Synced: 2024-10-12T12:51:26.524Z (3 months ago)
- Topics: mybatis, mybatis-page, mybatis-spring-boot-starter, mybatis-springboot, page, spring, spring-boot
- Language: Java
- Homepage: https://zoeminghong.github.io/spring-boot-starter-mybatis/
- Size: 25.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring-Boot-Starter-Mybatis
[![https://img.shields.io/github/release/zoeminghong/spring-boot-starter-mybatis.svg](https://img.shields.io/github/release/zoeminghong/spring-boot-starter-mybatis.svg)](http://search.maven.org/#search%7Cga%7C1%7Ccom.zerostech) ![https://img.shields.io/github/license/zoeminghong/spring-boot-starter-mybatis.svg](https://img.shields.io/github/license/zoeminghong/spring-boot-starter-mybatis.svg)
基于Spring Boot和Mybatis,添加分页相关功能,免配置即可用
## 依赖
spring boot:1.5.6
mybatis-spring-boot-starter:1.3.1
cluster-common:1.2.2-RC
## 快速开始
1. 添加依赖
```xml
com.zerostech
spring-boot-starter-mybatis
${lastest.version}```
2. JDBC配置
```yaml
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:test
schema: classpath:db/schema.sql
data: classpath:db/data.sql
```3. MyBatis配置
```yaml
mybatis:
type-aliases-package: com.zeros.demo.model
type-handlers-package: com.zerso.demo.typehandler
configuration:
map-underscore-to-camel-case: true
default-fetch-size: 100
default-statement-timeout: 30
```4. 服务
```java
@Mapper
public interface RoleDao {@Select("SELECT * FROM t_role WHERE id = #{id}")
Role findById(@Param("id") int id);@Select("SELECT * FROM t_role")
List fetchRoles();
}
``````java
@GetMapping
public Resp> fetchRoles() {
MybatisPageContext.setPageRequest(new MybatisPageContext.PageRequest(1, 2));
roleDao.fetchRoles();
Page roleResponsePage = MybatisPageContext.getPage();
MybatisPageContext.clearAll();
return Resp.success(roleResponsePage);
}
```## 演示
项目目录`example/mybatis-demo`
## 参考
[Mybatis](http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/)
[Spring Boot Reference](http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/)