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

然后,编写执行脚本

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. python 如何让俩个对象相等及如何让俩个对象具有相同的id值

  2. kylin剪枝优化的两种方式

    1.衍生维度. 在kylin中,如果某些维度都属于同一种类型,且数量较多,可以考虑做成衍生维度. 衍生维度就是将一批维度做成一张维度表,只在源表中保留这张表的外键,这样预处理的时候,就只会处理这个外键 ...

  3. Go语言web开发---Beego的session

    一.简介 Session是一段保存在服务器上的信息,当客户端第一次访问服务器时创建Session,同时也会创建一个名为beegosessionID,值为创建的Session的id的Cookie. 这个 ...

  4. Keil MDK5 安装教程(附安装包百度云)

    关注微信公众号"龙行单片机",后台回复"安装包"获取最新安装包百度云链接. 1.MDK5.11a 安装 双击 mdk511a.exe,进行安装.这里我们将其安装 ...

  5. Google Pixel 超分辨率--Super Resolution Zoom

    Google Pixel 超分辨率--Super Resolution Zoom Google 的Super Res Zoom技术,主要用于在zoom时增强画面细节以及提升在夜景下的效果. 文章的主要 ...

  6. MindSpore模型精度调优实践

    MindSpore模型精度调优实践 引论:在模型的开发过程中,精度达不到预期常常让人头疼.为了帮助用户解决模型调试调优的问题,为MindSpore量身定做了可视化调试调优组件:MindInsight. ...

  7. TensorFlow实现超参数调整

    TensorFlow实现超参数调整 正如你目前所看到的,神经网络的性能非常依赖超参数.因此,了解这些参数如何影响网络变得至关重要. 常见的超参数是学习率.正则化器.正则化系数.隐藏层的维数.初始权重值 ...

  8. GitHub上YOLOv5开源代码的训练数据定义

    GitHub上YOLOv5开源代码的训练数据定义 代码地址:https://github.com/ultralytics/YOLOv5 训练数据定义地址:https://github.com/ultr ...

  9. 高效Tensor张量生成

    高效Tensor张量生成 Efficient Tensor Creation 从C++中的Excel数据中创建Tensor张量的方法有很多种,在简单性和性能之间都有不同的折衷.本文讨论了一些方法及其权 ...

  10. 如何在小型pcb的移动设备上获得更好的无线性能

    如何在小型pcb的移动设备上获得更好的无线性能 How to get better wireless performance for mobile devices with small PCBs 小型 ...