首先,我们需要建好相关文件夹目录:

然后,编写执行脚本

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逆向工程生成类文件的更多相关文章

  1. MyBatis逆向工程生成的Example类的方法总结

    很早之前就在项目开发中多次使用MyBatis逆向工程生成的Example类,但一直没有对其下的方法做一个简单的总结,现总结如下:一.mapper接口中的方法解析mapper接口中的部分常用方法及功能如 ...

  2. 【坑】Mybatis 多次逆向工程生成mapper文件

    在使用 mybatis 逆向工程的时候,多次逆向工程生成的文件,是不会产生覆盖的,而是追加: 假如,你第一次逆向,发生数据库的某个字段类型错了,修改以后再次逆向,那么得到的 mapper文件,将是 2 ...

  3. Mybatis逆向工程生成po、mapper接口、mapper.xml

    Mybatis逆向工程生成po.mapper接口.mapper.xml 一.新建一个maven工程 请查看我的另一篇博客:<使用idea创建一个maven工程> 二.引入所需依赖 需要my ...

  4. MyBatis逆向工程生成配置 generator (生成pojo、mapper.xml、mapper.java)

    MyBatis逆向工程生成 mybatis需要程序员自己编写sql语句,mybatis官方提供逆向工程,可以针对单表自动生成mybatis执行所需要的代码(mapper.java.mapper.xml ...

  5. Mybatis自动生成xml文件、dao接口、实体类

    Mybatis可以通过逆向工程,实现自动生成xml文件.dao接口.实体类 以下使用的是Intellij Idea进行自动生成 一.首先,要在pom.xml中导入插件,在<build>中加 ...

  6. mybatis逆向工程生成mapper报错

    Result Maps collection already contains value for xxxMapper.BaseResultMap错误解决办法一.问题描述今天在做项目时,遇到一个错误: ...

  7. 使用最新版Mybatis逆向工程生成属性不全的问题

    这是出现问题时打印的日志 首先查看表内的字段 这张User表含8个属性,但是在逆向工程过程中生成的Pojo类不全还出现了不存在的属性 主要在逆向工程过程中的一个配置问题,修改generatorConf ...

  8. mybatis逆向工程生成JavaBean、dao、mapper generatorSqlmapCustom

    import java.io.File; import java.util.ArrayList; import java.util.List; import org.mybatis.generator ...

  9. mybatis逆向工程生成代码

    1 什么是逆向工程 mybaits需要程序员自己编写sql语句,mybatis官方提供逆向工程 可以针对单表自动生成mybatis执行所需要的代码(mapper.java,mapper.xml.po. ...

随机推荐

  1. HTTP、TCP、UDP,Socket,HTTPS

    TCP   HTTP   UDP三者的关系如下: TCP/IP是个协议组,可分为四个层次:网络接口层.网络层.传输层和应用层. 在网络层有IP协议.ICMP协议.ARP协议.RARP协议和BOOTP协 ...

  2. S11 Linux系统管理命令

    11.1 lsof:查看进程打开的文件 11.2 uptime:显示系统的运行时间及负载 11.3 free:查看系统内存信息 11.4 iftop:动态显示网络接口流量信息 11.5 vmstat: ...

  3. flink的checkpoint页面监控

    flink web页面中提供了针对Job Checkpoint相关的监控信息.Checkpoint监控页面共有overview.history.summary和configuration四个页签,分别 ...

  4. clickhouse_各个引擎表的特点

    去重表:RepalcingMergeTree 1.使用order by排序键作为判断重复数据的唯一键 2.只有在合并分区的时候才会触发删除重复数据的逻辑 3.以数据分区为单位删除重复数据.当分区合并时 ...

  5. Spring Cloud Alibaba系列之分布式服务组件Dubbo

    本博客的例子代码可以在github找到下载链接:代码下载 SpringBoot.SpringCloud Alibaba系列博客专栏:链接 1.分布式理论 1.1.分布式基本定义 <分布式系统原理 ...

  6. WPF中Grid容器中VerticalAlignment和HorizonAlignment和Margin的关系。

    在WPF中,经常使用Grid容器,来布局我们想要显示的对象. 这就不可避免的要和布局在其中的控件的VerticalAlignment特性,HorizonAlignment特性,以及Magin特性打交道 ...

  7. 深度树匹配模型(TDM)

    深度树匹配模型(TDM) 算法介绍 Tree-based Deep Match(TDM)是由阿里妈妈精准定向广告算法团队自主研发,基于深度学习上的大规模(千万级+)推荐系统算法框架.在大规模推荐系统的 ...

  8. LCD: 2D-3D匹配算法

    LCD: 2D-3D匹配算法 标题:LCD:Learned Cross-Domain Descriptors for 2D-3D Matching 作者:Quang-Hieu Pham, Mikael ...

  9. 如何选择视觉CV光源颜色

    如何选择视觉CV光源颜色 一.光源颜色分类 光源颜色的选择对机器视觉光源有什么影响及意义呢,常用的光源颜色有白色(W).蓝色(B).红色(R).绿色(G).红外光(IR).紫外光(UV),这六种颜色. ...

  10. IOS小组件(8):App与Widget数据共享

    引言   Widget是一个迷你版的App,IOS有沙盒机制,不同App之间无法直接共享数据.组件和主App之间其实就是不同App的关系,所以也无法通过userdefaults.standard来传数 ...