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. ...
随机推荐
- 下面附上top和sar的使用方法,方便参考! "top"工具
下面附上top和sar的使用方法,方便参考! "top"工具 使用方式:top [-] [d delay] [q] [c] [S] [s] [i] [n] [b] 说明:即时显示 ...
- elk搜集日志,实现logstash根据message中结构不同动态创建索引并扩展功能,区分message中json和非json数据简单方式
搜集日志,但是框架本身也会打印很多日志是字符串的.我们自己希望的日志用json,但是又需要json字段可以扩展,logstash收集日志后都放在了message字段中,我们自定义打印的是json串,s ...
- 圆盘时钟效果 原生JS
圆盘时钟 旋转时钟 数字时钟 写在前面 仿荣耀手机时钟,设计的同款时钟效果 实现效果 实现原理 数字时钟 利用Date内置对象获取当下的时间,通过处理呈现在页面上 这一步获取时间是非常简单的,通过Da ...
- Navigation DialogFragment展示dialog
如果按照一般fragment的写法: 在nav_config中 <fragment android:id="@+id/fragment_crime_detail" andro ...
- Ubuntu16.04下使用ufw保护docker容器
ufw屏蔽服务器非docker容器应用端口没有任何问题.问题出在屏蔽不了容器应用对应端口.排除了"ufw使用不当"."docker-compose.yml端口映射不正 ...
- cachecloud生产环境搭建
步骤 1 机器管理 机器初始化Redis环境 添加机器 执行: cachecloud-init.sh脚本 2 cachecloud添加机器的时候需要添加一个用户cachecloud-open ad ...
- Go语言流程控制05--defer延时执行
package main import "fmt" func xingzuoZhensuo() { var birthday string fmt.Println("请输 ...
- 3D惯导Lidar SLAM
3D惯导Lidar SLAM LIPS: LiDAR-Inertial 3D Plane SLAM 摘要 本文提出了最*点*面表示的形式化方法,并分析了其在三维室内同步定位与映射中的应用.提出了一个利 ...
- 基于TensorRT车辆实时推理优化
基于TensorRT车辆实时推理优化 Optimizing NVIDIA TensorRT Conversion for Real-time Inference on Autonomous Vehic ...
- 编译器架构Compiler Architecture(上)
编译器架构Compiler Architecture(上) 编译器是程序,通常是非常大的程序.它们几乎都有一个基于翻译分析综合模型的结构. CONTENTS Overview • Compiler C ...