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. ...
随机推荐
- 记一次 .NET 某电商交易平台Web站 CPU爆高分析
一:背景 1. 讲故事 已经连续写了几篇关于内存暴涨的真实案例,有点麻木了,这篇换个口味,分享一个 CPU爆高 的案例,前段时间有位朋友在 wx 上找到我,说他的一个老项目经常收到 CPU > ...
- kylin优化的思想
kylin的核心优势在于使用额外的空间存储预计算的结果,以换取查询时间的缩减. 所以我们要对额外的空间进行优化,并且在空间优化之后,cuboid无法完全命中时,对查询时间进行优化. 空间优化的思路就是 ...
- Qt 搜索框
一.前言 用户需要输入文本时,可使用QLineEdit控件进行编辑输入,缺点是样式相对单一. 在使用百度搜索输入框时,发觉比较人性化,故采用QLineEdt+QPushButton通过css样式实现自 ...
- 西门子 S7-200 以太网模块连接 WINCC步骤
北京华科远创科技有限研发的远创智控ETH-YC模块,PLC转以太网型号有MPI-ETH-YC01和MPI-ETH-YC01,适用于西门子S7-200/S7-300/S7-400.SMART S7-20 ...
- 在Visual Studio 中使用git——分支管理-上(八)
在Visual Studio 中使用git--什么是Git(一) 在Visual Studio 中使用git--给Visual Studio安装 git插件(二) 在Visual Studio 中使用 ...
- supervisor 使 celery后台运行
1.安装 supervisor pip install supervisor 2.创建supervisor配置文件,命令如下: 进入项目文件 echo_supervisord_conf > s ...
- 201871030132-熊文婷 实验二 个人项目―《D{0-1}KP问题》项目报告
项目 内容 课程班级博客链接 https://edu.cnblogs.com/campus/xbsf/2018CST 这个作业要求链接 https://www.cnblogs.com/nwnu-dai ...
- DLPack构建跨框架的深度学习编译器
DLPack构建跨框架的深度学习编译器 Tensorflow,PyTorch和ApacheMxNet等深度学习框架提供了一个功能强大的工具包,可用于快速进行原型设计和部署深度学习模型.易用性通常是以碎 ...
- 深度学习LiDAR定位:L3-Net
深度学习LiDAR定位:L3-Net 摘要 本文提出L3-Net--一种新颖的基于学习的LiDAR定位系统,可实现厘米级的定位,与现有最高水平的传统定位算法相媲美.与传统定位算法不同,本文创新地实现了 ...
- 使用CUDA Warp-Level级原语
使用CUDA Warp-Level级原语 NVIDIA GPU以SIMT(单指令,多线程)的方式执行称为warps 的线程组.许多CUDA程序通过利用warp执行来实现高性能.本文将展示如何使用cud ...