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接口以及它的映射文件,然后直接拷贝到 ...
随机推荐
- hexo创建的tags和categories页面为空的解决办法
title: hexo创建的tags和categories页面为空的解决办法 toc: false date: 2018-04-16 02:26:10 主题:landscape 添加type以及men ...
- java web项目中资源国际化
有一些网站会有语言栏选项: 选择英文,内容就显示为英文: 选择中文,内容就显示文中文. 这里就用到了国际化资源. 先看效果图: 步骤: 1.建立资源包: mess_en_US.properties ( ...
- accept-language
Chrome: [zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4]Safari: [zh-tw]FF: [zh-TW,zh;q=0.8,en-US;q=0.5,en;q=0.3 ...
- 新疆大学(新大)OJ xju 1010: 四个年级 C++ STL map 将4层循环优化成2层循环可解
1010: 四个年级 时间限制: 3 Sec 内存限制: 128 MB 题目描述 为了加强全体软件学院的同学的较量,学院想让ACM协会设计一次活动让所以软件学院的同学都加入,并且要实现高年级和低年级 ...
- python编程基础
Date: 2019-05-27 Author: Sun 1. 程序 为了完成某种特定功能,以某种程序设计语言编写的有序指令的集合.程序是指挥cpu工作的"工作手册".计算机只能执 ...
- TypeError: Cannot use 'in' operator to search for 'length' in....
前台页面读取商品属性是字符串形式,数据库中存储商品属性是集合形式,前台数据存入数据库中数据格式会自动转,后台数据回显到前台数据格式需要手动转换,否则会报异常 错误信息提示:
- 快速沃尔什变换(FWT)笔记
开头Orz hy,Orz yrx 部分转载自hy的博客 快速沃尔什变换,可以快速计算两个多项式的位运算卷积(即and,or和xor) 问题模型如下: 给出两个多项式$A(x)$,$B(x)$,求$C( ...
- vue项目的webpack4.X配置
这两天摆弄webpack,躺过很多坑,直到今天看了一位博主的文章才得以解决.他对配置中的各个部分做说明. 下面的配置99.9%抄自博主: https://www.cnblogs.com/nianyif ...
- PHP中使用DOM读取解析XML属性值一例
先看XML文件结构,与常见的文件略有不同,数据并不是用闭合标签保存的,而是直接保存在属性值中. <?xml version="1.0" encoding="utf- ...
- nginx 多级7层代理安装配置
编译安装 yum install zlib-devel -y wget https://nginx.org/download/nginx-1.15.12.tar.gz tar -zxf nginx-1 ...