Mybatis逆向工程生成类文件
首先,我们需要建好相关文件夹目录:

然后,编写执行脚本
generator.xml :
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
3 <generatorConfiguration>
4 <!-- 数据库驱动包位置:jdbc驱动放置的位置 -->
5 <classPathEntry location="F:\Users\LHN_admin\Desktop\spring+springmvc+mybaties+maven\generator\mysql-connector-java-5.1.6.jar"/>
6
7 <context id="DB2Tables" targetRuntime="MyBatis3">
8 <commentGenerator>
9 <property name="suppressAllComments" value="true" />
10 </commentGenerator>
11 <!-- 数据库链接URL、用户名、密码:动态添加 -->
12 <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/shop" userId="root" password="123456">
13
14 </jdbcConnection>
15 <javaTypeResolver>
16 <property name="forceBigDecimals" value="false" />
17 </javaTypeResolver>
18 <!-- 生成模型的包名和位置:动态添加 -->
19 <javaModelGenerator targetPackage="com.lhn.model" targetProject="F:\Users\LHN_admin\Desktop\spring+springmvc+mybaties+maven\generator\src">
20 <property name="enableSubPackages" value="true" />
21 <property name="trimStrings" value="true" />
22 </javaModelGenerator>
23 <!-- 生成的映射文件包名和位置:动态添加 -->
24 <sqlMapGenerator targetPackage="com.lhn.mapping" targetProject="F:\Users\LHN_admin\Desktop\spring+springmvc+mybaties+maven\generator\src">
25 <property name="enableSubPackages" value="true" />
26 </sqlMapGenerator>
27 <!-- 生成DAO的包名和位置:动态添加 -->
28 <javaClientGenerator type="XMLMAPPER" targetPackage="com.lhn.dao" targetProject="F:\Users\LHN_admin\Desktop\spring+springmvc+mybaties+maven\generator\src">
29 <property name="enableSubPackages" value="true" />
30 </javaClientGenerator>
31 <!-- 要生成的表(tableName:表名和domainObjectName:实体类名,其他照写(防止中文乱码)) -->
32 <table tableName="adminuser" domainObjectName="Adminuser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
33 <table tableName="category" domainObjectName="Category" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
34 <table tableName="categorysecond" domainObjectName="Categorysecond" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
35 <table tableName="company" domainObjectName="Company" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
36 <table tableName="feed" domainObjectName="Feed" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
37 <table tableName="news" domainObjectName="News" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
38 <table tableName="notice" domainObjectName="Notice" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
39 <table tableName="orderitem" domainObjectName="OrderItem" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
40 <table tableName="orders" domainObjectName="Orders" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
41 <table tableName="product" domainObjectName="Product" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
42 <table tableName="user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
43 </context>
44 </generatorConfiguration>
最后执行该脚本:
在目录空白位置上shift+右键

-->点击在此处打开命令窗口(M)

-->输入
1 java -jar mybatis-generator-core-1.3.2.jar -configfile generator.xml -overwrite
结束,,,,逆向工程生成完成!!!
还有通过java项目生成的逆向工程,我们下次再介绍。。。。。。
Mybatis逆向工程生成类文件的更多相关文章
- MyBatis逆向工程生成的Example类的方法总结
很早之前就在项目开发中多次使用MyBatis逆向工程生成的Example类,但一直没有对其下的方法做一个简单的总结,现总结如下:一.mapper接口中的方法解析mapper接口中的部分常用方法及功能如 ...
- 【坑】Mybatis 多次逆向工程生成mapper文件
在使用 mybatis 逆向工程的时候,多次逆向工程生成的文件,是不会产生覆盖的,而是追加: 假如,你第一次逆向,发生数据库的某个字段类型错了,修改以后再次逆向,那么得到的 mapper文件,将是 2 ...
- Mybatis逆向工程生成po、mapper接口、mapper.xml
Mybatis逆向工程生成po.mapper接口.mapper.xml 一.新建一个maven工程 请查看我的另一篇博客:<使用idea创建一个maven工程> 二.引入所需依赖 需要my ...
- MyBatis逆向工程生成配置 generator (生成pojo、mapper.xml、mapper.java)
MyBatis逆向工程生成 mybatis需要程序员自己编写sql语句,mybatis官方提供逆向工程,可以针对单表自动生成mybatis执行所需要的代码(mapper.java.mapper.xml ...
- Mybatis自动生成xml文件、dao接口、实体类
Mybatis可以通过逆向工程,实现自动生成xml文件.dao接口.实体类 以下使用的是Intellij Idea进行自动生成 一.首先,要在pom.xml中导入插件,在<build>中加 ...
- mybatis逆向工程生成mapper报错
Result Maps collection already contains value for xxxMapper.BaseResultMap错误解决办法一.问题描述今天在做项目时,遇到一个错误: ...
- 使用最新版Mybatis逆向工程生成属性不全的问题
这是出现问题时打印的日志 首先查看表内的字段 这张User表含8个属性,但是在逆向工程过程中生成的Pojo类不全还出现了不存在的属性 主要在逆向工程过程中的一个配置问题,修改generatorConf ...
- mybatis逆向工程生成JavaBean、dao、mapper generatorSqlmapCustom
import java.io.File; import java.util.ArrayList; import java.util.List; import org.mybatis.generator ...
- mybatis逆向工程生成代码
1 什么是逆向工程 mybaits需要程序员自己编写sql语句,mybatis官方提供逆向工程 可以针对单表自动生成mybatis执行所需要的代码(mapper.java,mapper.xml.po. ...
随机推荐
- zabbix监控之邮件报警通知
zabbix官网的操作指南:https://www.zabbix.com/documentation/4.0/zh/manual 首先我们需要创建一个需要被监控的主机,并设置相应的监控项.当监控项收集 ...
- centos7 的Linux下ip命令替换ifconfig命令的用法
linux的ip命令和ifconfig类似,但前者功能更强大,并旨在取代后者.使用ip命令,只需一个命令,你就能很轻松地执行一些网络管理任务.ifconfig是net-tools中已被废弃使用的一个命 ...
- js闭包和包装类
闭包 内部函数被返回到外部,函数本身保留了父函数的AO,即使父元素执行完了,取消对AO的引用,但依旧被子函数保留下来了,就形成了闭包. 闭包会导致原有作用域链不释放,造成内存泄漏. 作用 实现公有变量 ...
- Hadoop MapReduce 一文详解MapReduce及工作机制
@ 目录 前言-MR概述 1.Hadoop MapReduce设计思想及优缺点 设计思想 优点: 缺点: 2. Hadoop MapReduce核心思想 3.MapReduce工作机制 剖析MapRe ...
- Step By Step(userdata)
Step By Step(userdata) 在Lua中可以通过自定义类型的方式与C语言代码更高效.更灵活的交互.这里我们通过一个简单完整的示例来学习一下Lua中userdata的使用方式.需要说明的 ...
- 查询rman备份信息常用指令
查询rman备份信息常用指令 ----登陆到rman $rman target / ----以精简的格式查看备份信息 RMAN> list backup of database summar ...
- MindSpore 高阶优化器
MindSpore 高阶优化器 MindSpore自研优化器THOR(Trace-based Hardware-driven layer-ORiented Natural Gradient Desce ...
- MinkowskiEngine demo ModelNet40分类
MinkowskiEngine demo ModelNet40分类 本文将看一个简单的演示示例,该示例训练用于分类的3D卷积神经网络.输入是稀疏张量,卷积也定义在稀疏张量上.该网络是以下体系结构的扩展 ...
- nvGRAPH API参考分析(一)
nvGRAPH API参考分析(一) 本文通过描述nvGRAPH库函数的输入/输出参数,数据类型和错误代码来指定其行为. 1. 返回值nvgraphStatus_t 除以下内容外,所有nvGRA ...
- MySQL必知必会笔记-Mysql基本操作
Mysql基本操作 mysql的基本操作包括增.删.改.查,本书中前三章简单的介绍MySQL为何物,查是mysql中非常重要的功能,4-6章展示了mysql的查(查询--select)的简单实现,my ...