写在前面:
Mybatis Generator 是 MyBatis 和 ibatis 的代码生成器. 主要生成如下:
(1)与表结构匹配的 Java POJO(字段名对应属性)
(2)SQL 映射 xml 文件 (文件为配置中每个表上的简单 CRUD(增删改查) 函数生成 SQL.)
生成的 SQL 语句有
- insert
- update by primary key
- update by example (使用动态 where 子句)
- delete by primary key
- delete by example (使用动态 where 子句)
- select by primary key
- select by example (使用动态 where 子句)
- count by example
(3)符合 Spring 框架的 DAO 接口 java 类
* 官方文档地址: http://www.mybatis.org/generator/
具体步骤
(一)建立 Project:
简略
(二)导入 jar 包
(1)非 maven 方式: 主要 jar 包:
. 其他的必要 jar 包如 MyBatis, 数据库驱动同时需要.
(2)maven 依赖: maven 仓库:
具体依赖如下:
- <dependency>
- <groupId>org.mybatis.generator</groupId>
- <artifactId>mybatis-generator-core</artifactId>
- <version>1.3.5</version>
- </dependency>
MyBatis 逆向工程 --MyBatis Generator (MBG)- 简单介绍与运行步骤(1)
来源: http://www.bubuko.com/infodetail-2935176.html