Spring-Boot-Starter-Mybatis

Spring Boot with Mybatis and Page support.

License

License

Categories

Categories

Spring Boot Container Microservices MyBatis Data ORM
GroupId

GroupId

com.zerostech
ArtifactId

ArtifactId

spring-boot-starter-mybatis
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Spring-Boot-Starter-Mybatis
Spring Boot with Mybatis and Page support.
Project URL

Project URL

https://github.com/zoeminghong/spring-boot-starter-mybatis
Project Organization

Project Organization

Zeros Technology
Source Code Management

Source Code Management

https://github.com/zoeminghong/spring-boot-starter-mybatis

Download spring-boot-starter-mybatis

How to add to project

<!-- https://jarcasting.com/artifacts/com.zerostech/spring-boot-starter-mybatis/ -->
<dependency>
    <groupId>com.zerostech</groupId>
    <artifactId>spring-boot-starter-mybatis</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.zerostech/spring-boot-starter-mybatis/
implementation 'com.zerostech:spring-boot-starter-mybatis:1.0.0'
// https://jarcasting.com/artifacts/com.zerostech/spring-boot-starter-mybatis/
implementation ("com.zerostech:spring-boot-starter-mybatis:1.0.0")
'com.zerostech:spring-boot-starter-mybatis:jar:1.0.0'
<dependency org="com.zerostech" name="spring-boot-starter-mybatis" rev="1.0.0">
  <artifact name="spring-boot-starter-mybatis" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.zerostech', module='spring-boot-starter-mybatis', version='1.0.0')
)
libraryDependencies += "com.zerostech" % "spring-boot-starter-mybatis" % "1.0.0"
[com.zerostech/spring-boot-starter-mybatis "1.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
com.ecfront.dew : cluster-common jar 1.2.2-RC
org.mybatis.spring.boot : mybatis-spring-boot-starter jar 1.3.1

Project Modules

There are no modules declared in this project.

Spring-Boot-Starter-Mybatis

https://img.shields.io/github/release/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. 添加依赖
<dependency>
    <groupId>com.zerostech</groupId>
    <artifactId>spring-boot-starter-mybatis</artifactId>
    <version>${lastest.version}</version>
</dependency>
  1. JDBC配置
spring:
  datasource:
    driver-class-name: org.h2.Driver
    url: jdbc:h2:mem:test
    schema: classpath:db/schema.sql
    data: classpath:db/data.sql    
  1. MyBatis配置
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
  1. 服务
@Mapper
public interface RoleDao {

    @Select("SELECT * FROM t_role WHERE id = #{id}")
    Role findById(@Param("id") int id);

    @Select("SELECT * FROM t_role")
    List<Role> fetchRoles();
}
@GetMapping
public Resp<Page<Role>> fetchRoles() {           
  MybatisPageContext.setPageRequest(new MybatisPageContext.PageRequest(1, 2));
  roleDao.fetchRoles();
  Page<Role> roleResponsePage = MybatisPageContext.getPage();
  MybatisPageContext.clearAll();
  return Resp.success(roleResponsePage);
}

演示

项目目录example/mybatis-demo

参考

Mybatis

Spring Boot Reference

Versions

Version
1.0.0
0.0.5