{"id":13635445,"url":"https://github.com/houbb/mybatis","last_synced_at":"2025-04-10T18:31:26.660Z","repository":{"id":37381038,"uuid":"276059998","full_name":"houbb/mybatis","owner":"houbb","description":"The simple mybatis.（手写简易版 mybatis）","archived":false,"fork":false,"pushed_at":"2023-10-22T14:22:22.000Z","size":164,"stargazers_count":28,"open_issues_count":2,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T02:51:34.777Z","etag":null,"topics":["handwriting","hibernate","hibernate-orm","ibatis","jdbc","jdbc-driver","jpa","mybatis","orm"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/houbb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-30T09:49:51.000Z","updated_at":"2025-03-17T16:46:32.000Z","dependencies_parsed_at":"2022-09-26T21:41:15.028Z","dependency_job_id":"2d9245c9-f96f-47a0-be49-dfcd75299636","html_url":"https://github.com/houbb/mybatis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fmybatis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fmybatis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fmybatis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fmybatis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/houbb","download_url":"https://codeload.github.com/houbb/mybatis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248271722,"owners_count":21075800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["handwriting","hibernate","hibernate-orm","ibatis","jdbc","jdbc-driver","jpa","mybatis","orm"],"created_at":"2024-08-02T00:00:45.654Z","updated_at":"2025-04-10T18:31:25.851Z","avatar_url":"https://github.com/houbb.png","language":"Java","readme":"# 项目简介\n\n[mybatis](https://github.com/houbb/mybatis) 是一款简化版的 mybatis 实现。\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.houbb/mybatis/badge.svg)](http://mvnrepository.com/artifact/com.github.houbb/mybatis)\n[![Build Status](https://www.travis-ci.org/houbb/mybatis.svg?branch=master)](https://www.travis-ci.org/houbb/mybatis?branch=master)\n[![](https://img.shields.io/badge/license-Apache2-FF0080.svg)](https://github.com/houbb/mybatis/blob/master/LICENSE.txt)\n[![Open Source Love](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/houbb/mybatis)\n\n## 创作目的\n\n- 学习 mybatis 的原理\n\n- 便于拓展自己的数据库工具\n\n# 快速开始\n\n## 需要\n\n- jdk 1.7+\n\n- maven 3.x+\n\n## maven 引入\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.houbb\u003c/groupId\u003e\n    \u003cartifactId\u003emybatis\u003c/artifactId\u003e\n    \u003cversion\u003e0.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## 准备工作\n\n- sql 建表\n\n在 test 数据库执行下面的建表语句。\n\n```sql\n-- auto-generated definition\nuse test;\ncreate table user\n(\n  id   int auto_increment\n    primary key comment '唯一主键',\n  name varchar(100) not null comment '姓名',\n  password varchar(100) not null comment '密码',\n  create_time char(17) comment '创建时间'\n) CHARACTER SET utf8 COLLATE utf8_general_ci;\n\n-- init\ninsert into user (name, password) value ('luna', '123456');\n```\n\n- 配置文件\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cconfiguration\u003e\n\n    \u003cdataSource\u003e\n        \u003cproperty name=\"driver\" value=\"com.mysql.jdbc.Driver\"/\u003e\n        \u003cproperty name=\"url\" value=\"jdbc:mysql://localhost:3306/test\"/\u003e\n        \u003cproperty name=\"username\" value=\"root\"/\u003e\n        \u003cproperty name=\"password\" value=\"123456\"/\u003e\n    \u003c/dataSource\u003e\n\n    \u003cmappers\u003e\n        \u003cmapper resource=\"mapper/UserMapper.xml\"/\u003e\n    \u003c/mappers\u003e\n\n    \u003cplugins\u003e\n        \u003cplugin interceptor=\"com.github.houbb.mybatis.plugin.SimpleLogInterceptor\"/\u003e\n    \u003c/plugins\u003e\n\n    \u003ctypeHandlers\u003e\n        \u003ctypeHandler javaType=\"java.util.Date\" handler=\"com.github.houbb.mybatis.typehandler.DateTypeHandler\"/\u003e\n    \u003c/typeHandlers\u003e\n\n\u003c/configuration\u003e\n```\n\n备注：默认使用的是 mysql 5.7，如果为 8.0+，需要自行引入 jar。\n\n## 运行测试代码\n\n```java\npublic static void main(String[] args) {\n    Config config = new XmlConfig(\"mybatis-config-5-7.xml\");\n\n    SqlSession sqlSession = new DefaultSessionFactory(config).openSession();\n    UserMapper userMapper = sqlSession.getMapper(UserMapper.class);\n\n    User user = userMapper.selectById(1L);\n    System.out.println(user);\n}\n```\n\n- 输出\n\n```\nUser{id=1, name='ryo', password='123456', createTime=Wed Jul 01 22:03:01 CST 2020}\n```\n\n# 拓展阅读\n\n[从零开始手写 mybatis（一）MVP 版本](https://mp.weixin.qq.com/s/8eF7oFxgLsilqLYGOVtkGg)\n\n[手写 mybatis 系列（二）mybatis interceptor 插件机制详解](https://mp.weixin.qq.com/s?__biz=MzUyNjE3OTAyMw==\u0026mid=2247484124\u0026idx=1\u0026sn=0547e9a6535c1de74fe570a1ed1f9099\u0026chksm=fa138d7ccd64046a12343ab655dc748a48deeb2eae87aac29f49403eaedee99ed46c4923e9e9\u0026cur_album_id=1406621227405688832\u0026scene=189#wechat_redirect)\n\n[从零开始手写 mybatis （三）jdbc pool 从零实现数据库连接池](https://mp.weixin.qq.com/s?__biz=MzUyNjE3OTAyMw==\u0026mid=2247484130\u0026idx=1\u0026sn=0819286a310c9d1f77e57c28ca454925\u0026chksm=fa138d42cd6404545874def08da9870db5c8ab3f0777e310196f64ebaed40353c11cf0cae379\u0026cur_album_id=1406621227405688832\u0026scene=189#wechat_redirect)\n\n# 后期 road-map\n\n- [x] 日志组合\n\n- [x] 连接池管理\n\n- [x] TX 管理\n\n~~- [ ] 数据库厂商标识（databaseIdProvider）~~\n\n- [ ] api 方法配置全接口，便于直接配置使用。\n\n- [ ] 添加 MBG\n\n- [ ] 添加 spring 整合实现\n\n- [ ] 添加 spring-boot 整合实现\n\n- [ ] 自增强-类似 mybatis-plus 模块。让组件使用起来更加方便\n\n保持核心功能的简单，保证使用的强大便捷。\n","funding_links":[],"categories":["测试"],"sub_categories":["客户端"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoubb%2Fmybatis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoubb%2Fmybatis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoubb%2Fmybatis/lists"}