mybatis

The simple mybatis for java.

Лицензия

Лицензия

Категории

Категории

MyBatis Данные ORM
Группа

Группа

com.github.houbb
Идентификатор

Идентификатор

mybatis
Последняя версия

Последняя версия

0.0.18
Дата

Дата

Тип

Тип

jar
Описание

Описание

mybatis
The simple mybatis for java.
Система контроля версий

Система контроля версий

https://github.com/houbb/mybatis

Скачать mybatis

Как подключить последнюю версию

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

Зависимости

compile (4)

Идентификатор библиотеки Тип Версия
com.github.houbb : heaven jar 0.1.112
mysql : mysql-connector-java jar 5.1.29
dom4j : dom4j jar 1.6.1
org.apache.commons : commons-jexl3 jar 3.1

test (1)

Идентификатор библиотеки Тип Версия
junit : junit Необязательный jar 4.12

Модули Проекта

Данный проект не имеет модулей.

项目简介

mybatis 是一款简化版的 mybatis 实现。

Maven Central Build Status Open Source Love

创作目的

  • 学习 mybatis 的原理

  • 便于拓展自己的数据库工具

快速开始

需要

  • jdk 1.7+

  • maven 3.x+

maven 引入

<dependency>
    <groupId>com.github.houbb</groupId>
    <artifactId>mybatis</artifactId>
    <version>0.0.16</version>
</dependency>

准备工作

  • sql 建表

在 test 数据库执行下面的建表语句。

-- auto-generated definition
use test;
create table user
(
  id   int auto_increment
    primary key comment '唯一主键',
  name varchar(100) not null comment '姓名',
  password varchar(100) not null comment '密码',
  create_time char(17) comment '创建时间'
) CHARACTER SET utf8 COLLATE utf8_general_ci;

-- init
insert into user (name, password) value ('luna', '123456');
  • 配置文件
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <dataSource>
        <property name="driver" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/test"/>
        <property name="username" value="root"/>
        <property name="password" value="123456"/>
    </dataSource>

    <mappers>
        <mapper resource="mapper/UserMapper.xml"/>
    </mappers>

    <plugins>
        <plugin interceptor="com.github.houbb.mybatis.plugin.SimpleLogInterceptor"/>
    </plugins>

    <typeHandlers>
        <typeHandler javaType="java.util.Date" handler="com.github.houbb.mybatis.typehandler.DateTypeHandler"/>
    </typeHandlers>

</configuration>

备注:默认使用的是 mysql 5.7,如果为 8.0+,需要自行引入 jar。

运行测试代码

public static void main(String[] args) {
    Config config = new XmlConfig("mybatis-config-5-7.xml");

    SqlSession sqlSession = new DefaultSessionFactory(config).openSession();
    UserMapper userMapper = sqlSession.getMapper(UserMapper.class);

    User user = userMapper.selectById(1L);
    System.out.println(user);
}
  • 输出
User{id=1, name='ryo', password='123456', createTime=Wed Jul 01 22:03:01 CST 2020}

拓展阅读

从零开始手写 mybatis(一)MVP 版本

后期 road-map

  • 连接池管理

  • TX 管理

  • 数据库厂商标识(databaseIdProvider)

  • 添加 MBG

  • 添加 spring 整合实现

  • 添加 spring-boot 整合实现

Версии библиотеки

Версия
0.0.18
0.0.17
0.0.16
0.0.15
0.0.14
0.0.13
0.0.12
0.0.11
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1