mybatis-generator-core快速生成实体类和Mapper
日常使用Mybatis少不了和实体类和 Mapper 打交道。除了我们手写来实现,还可以使用 mybatis-generator-core 来快速生成 实体类和 Mapper。
步骤如下:
1、下载 mybatis-generator-core 到本地
下载链接:https://pan.baidu.com/s/1wTZ_7RTwToaW8oYm81WkLw 密码:lr6x
2、使用 IDEA 打开 mybatis-generator-core
3、配置 generatorConfig.xml 配置文件
<!--数据库URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/test?useUnicode=true" userId="root" password="root" />
<!--实体类存储的路径:C:\Users\my\Desktop\mybatis-generator-core-1.3.6\lib\java -->
<javaModelGenerator targetPackage="javaModelGenerator"
targetProject="C:\Users\my\Desktop\mybatis-generator-core-1.3.6\lib\java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!--Mapper类存储的路径:C:\Users\my\Desktop\mybatis-generator-core-1.3.6\lib\java-->
<sqlMapGenerator targetPackage="sqlMapGenerator"
targetProject="C:\Users\my\Desktop\mybatis-generator-core-1.3.6\lib\java">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!--Mapper插入时判断字段非空类存储的路径:C:\Users\my\Desktop\mybatis-generator-core-1.3.6\lib\java-->
<javaClientGenerator type="ANNOTATEDMAPPER" targetPackage="javaClientGenerator"
targetProject="C:\Users\my\Desktop\mybatis-generator-core-1.3.6\lib\java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!--可一次指定多个表,这里指定了 6 个表-->
<!-- 指定生成的表: tableName是数据库中的表名 domainObjectName是要生成的实体类名-->
<!-- mybatis generator代码生成器在默认的情况下会生成对于表实体类的一个Examle类,可以更改生成器的配置为false避免生成Examle类 -->
<!-- columnOverride:如果不存在则默认按数据库中字段类型创建实体类,如果存在则按以下指定的名称和类型创建实体类字段, -->
<!-- ignoreColumn:在实体类中不创建此属性 -->
<table tableName="wf_admin_action_logs" domainObjectName="AdminActionLogs" enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
</table>
<table tableName="wf_admin_menus" domainObjectName="AdminMenus" enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
</table>
<table tableName="wf_admin_roles" domainObjectName="AdminRoles" enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
</table>
<table tableName="wf_admin_roles_menus" domainObjectName="AdminRolesMenus" enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
</table>
<table tableName="wf_admin_users" domainObjectName="AdminUsers" enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
</table>
<table tableName="wf_admin_users_roles" domainObjectName="AdminUsersRoles" enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
</table>
4、IDEA打开命令行窗口或Windows+r打开命令行窗口
5、运行创建命令
//返回 MyBatis Generator finished successfully. 说明创建成功
java -jar mybatis-generator-core-1.3.6.jar -configfile generatorConfig.xml -overwrite
thanks~
mybatis-generator-core快速生成实体类和Mapper的更多相关文章
- 使用eclipse插件mybatis generator来自动生成实体类及映射文件
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE generatorConfiguratio ...
- Springboot mybatis generate 自动生成实体类和Mapper
https://github.com/JasmineQian/SpringDemo_2019/tree/master/mybatis Springboot让java开发变得方便,Springboot中 ...
- mybatis根据表逆向自动化生成代码(自动生成实体类、mapper文件、mapper.xml文件)
.personSunflowerP { background: rgba(51, 153, 0, 0.66); border-bottom: 1px solid rgba(0, 102, 0, 1); ...
- idea快速生成实体类
1.打开idea的视图,选择Database 2.选择对应的数据库[这里是mysql为例] 3.输入自己对应的内容,输入完成可点击Test Connection进行测试,成功SUCCESS 4.点击确 ...
- 第二篇 Springboot mybatis generate根据数据库表自动生成实体类、Mapper和Mapper.xml
源码链接:https://pan.baidu.com/s/1iP4UguBufHbcIEv4Ux4wDw 提取码:j6z9 目录结构如下:只需增加一个generatorConfig.xml文件和在po ...
- 使用generatorConfig配置,自动生成实体类,Mapper接口等
1.在项目的resource目录下面配置generatorConfig.properties文件,以及generatorConfig.xml文件 generatorConfig.properties文 ...
- 使用maven的mybatis-generator代码生成器插件生成实体类、mapper配置文件和mapper接口(使用idea)
接着之前创建的ssmMaven项目 一: 在pom文件中加入mybatis-generator插件 <plugins> <plugin> <groupId>org. ...
- idea快速生成实体类Entity
1)打开idea 2)添加mysql的数据连接 3)生成类
- Mybatis自动生成实体类、dao接口和mapping映射文件
由于Mybatis是一种半自动的ORM框架,它的工作主要是配置mapping映射文件,为了减少手动书写映射文件,可以利用mybatis生成器,自动生成实体类.dao接口以及它的映射文件,然后直接拷贝到 ...
随机推荐
- hdoj--1260--Tickets(简单dp)
Tickets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...
- [JZOJ 5906] [NOIP2018模拟10.15] 传送门 解题报告(树形DP)
题目链接: https://jzoj.net/senior/#contest/show/2528/2 题目: 8102年,Normalgod在GLaDOS的帮助下,研制出了传送枪.但GLaDOS想把传 ...
- P3369 【模板】普通平衡树(Treap/SBT)(pb_ds版)
题目描述 您需要写一种数据结构(可参考题目标题),来维护一些数,其中需要提供以下操作: 插入x数 删除x数(若有多个相同的数,因只删除一个) 查询x数的排名(若有多个相同的数,因输出最小的排名) 查询 ...
- RGB颜色值与十六进制颜色码转换工具
RGB颜色值转换成十六进制颜色码: 十六进制颜色码转换成RGB颜色值: 颜色码对照表 颜色 英文代码 形象描述 十六进制 RGB LightPink 浅粉红 #FFB6C1 255, ...
- 【原创】Linux下的ngix服务器安装步骤
1.首先下载ngix的源码linux版本[1.5.8版本] http://nginx.org/en/download.html 2.下载PCRE library,是安装ngix的必备包之一 [root ...
- ActiveMQ学习笔记(6)----ActiveMQ整合Spring开发
1. 添加依赖 spring 提供了对JMS的支持,需要添加Spring支持jms的包和Spring的核心包,如下: <dependency> <groupId>org.apa ...
- Vue项目结合vux使用
引入vux 1.直接安装或者更新: npm install vux --save 或者使用 yarn yarn add vux // 安装 yarn upgrade vux // 更新 2.vux2必 ...
- es6 学习7 Set 和 Map 数据结构
Set 和 Map 数据结构 一.Set ES6 提供了新的数据结构 Set.它类似于数组,但是成员的值都是唯一的,没有重复的值. const set = new Set([1, 2, 3, 4, ...
- 获取mapper
static UpdateLogMapper updateLogMapper = (UpdateLogMapper)SpringContextUtil.getBean(UpdateLogMapper. ...
- 学习爬虫:《Python网络数据采集》中英文PDF+代码
适合爬虫入门的书籍<Python网络数据采集>,采用简洁强大的Python语言,介绍了网络数据采集,并为采集新式网络中的各种数据类型提供了全面的指导.第一部分重点介绍网络数据采集的基本原理 ...