MyBatis Generator使用方法
第一步:在resources文件夹下创建一个目录mybatis-generator,在目录mybatis-generator下创建文件generatorConfig.xml(此处的目录名可任意取)

第二步:在pom文件标签<plugins>处引入依赖
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<configuration>
<configurationFile>${basedir}/src/main/resources/mybatis-generator/generatorConfig.xml
</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
</plugin>
第三步:配置generatorConfig.xml
注:①标红处即为需要修改处
②"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" 在xml中会报错,可忽略
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration>
<!-- 连接数据库jar包的路径-->
<classPathEntry location="/Users/dxm1/.m2/repository/mysql/mysql-connector-java/5.1.48/mysql-connector-java-5.1.48.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator> <!--数据库连接参数 -->
<jdbcConnection
driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/test_db?serverTimezone=UTC&useSSL=false"
userId="root"
password="zu273334ly">
</jdbcConnection> <javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver> <!-- 实体类的包名和存放路径 -->
<javaModelGenerator targetPackage="com.example.demo.model" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator> <!-- 生成映射文件*.xml的位置-->
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator> <!-- 生成DAO的包名和位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.example.demo.dao" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator> <!-- tableName:数据库中的表名或视图名;domainObjectName:生成的实体类的类名-->
<table tableName="GENERAL_BALANCE_PLAN" domainObjectName="GeneralBalancePlan"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"/>
<!--
<table tableName="xxx" domainObjectName="xxx"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"/>
...
<table tableName="xxx" domainObjectName="xxx"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"/>
-->
</context>
</generatorConfiguration>
如何找连接数据库jar包的路径,可参考 https://blog.csdn.net/weixin_43228497/article/details/83114594
第四步:启动

参考资料: https://blog.csdn.net/weixin_42250302/article/details/106986707
MyBatis Generator使用方法的更多相关文章
- mybatis generator 使用方法
环境: ubuntu eclipse maven 一. 简介 mybatis-geneator是一款mybatis自动代码生成工具,可以通过配置,快速生成mapper和xml文件以及pojo 二. ...
- Mybatis Generator自动生成的mapper只有insert方法
– Mybatis Generator 生成的mapper只有insert方法 – 首先检查generatorConfig.xml中table项中的属性 enableSelectByPrimaryKe ...
- Mybatis Generator的model生成中文注释,支持oracle和mysql(通过实现CommentGenerator接口的方法来实现)
自己手动实现的前提,对maven项目有基本的了解,在本地成功搭建了maven环境,可以参考我之前的文章:maven环境搭建 项目里新建表时model,mapper以及mapper.xml基本都是用My ...
- mybatis generator自动生成sqlmap代码的不完善之处以及解决方法
a) 建表时,字段名称建议用"_"分隔多个单词,比如:AWB_NO.REC_ID...,这样生成的entity,属性名称就会变成漂亮的驼峰命名,即:awbNo.recId b)or ...
- Mybatis—三剑客之generator使用方法
三剑客之generator主要用于自动生成POJO实体类 准备素材: mybatis-generator-core-1.3.2.jar mysql-connector-java-5.1.2 ...
- mybatis Generator生成代码及使用方式
本文原创,转载请注明:http://www.cnblogs.com/fengzheng/p/5889312.html 为什么要有mybatis mybatis 是一个 Java 的 ORM 框架,OR ...
- mybatis generator 自动生成dao层映射代码
资源: doc url :http://www.mybatis.org/generator/ download:https://github.com/mybatis/generator/release ...
- MyBatis Generator作为maven插件自动生成增删改查代码及配置文件例子
什么是MyBatis Generator MyBatis Generator (MBG) 是一个Mybatis的代码生成器,可以自动生成一些简单的CRUD(插入,查询,更新,删除)操作代码,model ...
- Mybatis Generator生成工具配置文件详解
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...
- MyBatis Generator 详解
MyBatis Generator中文文档 MyBatis Generator中文文档地址:http://mbg.cndocs.tk/ 该中文文档由于尽可能和原文内容一致,所以有些地方如果不熟悉,看中 ...
随机推荐
- Visual Studio 快速生成构造函数
生成构造函数快速操作 - Visual Studio (Windows) | Microsoft Learn 键盘 按 (Ctrl+.) 触发"快速操作和重构"菜单. 鼠标 右键单 ...
- go-使用 vscore 调试 go 语言
{ // 使用 IntelliSense 了解相关属性. // 悬停以查看现有属性的描述. // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linki ...
- pyg安装
pyg官网:pytorch_geometric documentation (pytorch-geometric.readthedocs.io) win安装pyg各种报错,原因在于pytorch和py ...
- Virtualbox EFI 写入startup.nsh
安装好的Debian系统,重启后会因为找不到入口而无法启动.定位grubx64.efi文件,可用ls直接查找或一步一步查找ls fs0:\EFI\debian\grubx64.efi edit fs0 ...
- R语言Apriori关联规则、kmeans聚类、决策树挖掘研究京东商城网络购物用户行为数据可视化|附代码数据
全文链接:http://tecdat.cn/?p=30360 最近我们被客户要求撰写关于网络购物用户行为的研究报告,包括一些图形和统计输出. 随着网络的迅速发展,依托于网络的购物作为一种新型的消费方式 ...
- ES深分页
一.背景 1.ES默认分页from+size 2.在大数据量和深度分页的时候,效率非常低 二.效率低原因 1.例如要查第501页的10条数据,from为5000,size为10 2.ES会查询并排序5 ...
- Devexpress WPF ChartControl 多Y轴
<Window x:Class="DXApplication4.MainWindow" xmlns="http://schemas.microsoft.com/wi ...
- Double NaN
import java.math.BigDecimal; import java.math.RoundingMode; public class Test { public static void m ...
- hierarchical-clustering
https://ww2.mathworks.cn/help/stats/hierarchical-clustering.html https://ww2.mathworks.cn/help/stats ...
- RTT笔记-分析自动初始化机制转
首先全局搜索一个任意的自启动宏,便能找到在rtdef.h中由如下定义 1 #define INIT_BOARD_EXPORT(fn) INIT_EXPORT(fn, "1") 2 ...