第一步:在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&amp;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使用方法的更多相关文章

  1. mybatis generator 使用方法

    环境: ubuntu   eclipse maven 一. 简介 mybatis-geneator是一款mybatis自动代码生成工具,可以通过配置,快速生成mapper和xml文件以及pojo 二. ...

  2. Mybatis Generator自动生成的mapper只有insert方法

    – Mybatis Generator 生成的mapper只有insert方法 – 首先检查generatorConfig.xml中table项中的属性 enableSelectByPrimaryKe ...

  3. Mybatis Generator的model生成中文注释,支持oracle和mysql(通过实现CommentGenerator接口的方法来实现)

    自己手动实现的前提,对maven项目有基本的了解,在本地成功搭建了maven环境,可以参考我之前的文章:maven环境搭建 项目里新建表时model,mapper以及mapper.xml基本都是用My ...

  4. mybatis generator自动生成sqlmap代码的不完善之处以及解决方法

    a) 建表时,字段名称建议用"_"分隔多个单词,比如:AWB_NO.REC_ID...,这样生成的entity,属性名称就会变成漂亮的驼峰命名,即:awbNo.recId b)or ...

  5. Mybatis—三剑客之generator使用方法

    三剑客之generator主要用于自动生成POJO实体类   准备素材: mybatis-generator-core-1.3.2.jar     mysql-connector-java-5.1.2 ...

  6. mybatis Generator生成代码及使用方式

    本文原创,转载请注明:http://www.cnblogs.com/fengzheng/p/5889312.html 为什么要有mybatis mybatis 是一个 Java 的 ORM 框架,OR ...

  7. mybatis generator 自动生成dao层映射代码

    资源: doc url :http://www.mybatis.org/generator/ download:https://github.com/mybatis/generator/release ...

  8. MyBatis Generator作为maven插件自动生成增删改查代码及配置文件例子

    什么是MyBatis Generator MyBatis Generator (MBG) 是一个Mybatis的代码生成器,可以自动生成一些简单的CRUD(插入,查询,更新,删除)操作代码,model ...

  9. Mybatis Generator生成工具配置文件详解

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...

  10. MyBatis Generator 详解

    MyBatis Generator中文文档 MyBatis Generator中文文档地址:http://mbg.cndocs.tk/ 该中文文档由于尽可能和原文内容一致,所以有些地方如果不熟悉,看中 ...

随机推荐

  1. SQL正则查询--查询有效邮箱

    用户表: Users +---------------+---------+| Column Name | Type |+---------------+---------+| user_id | i ...

  2. 性能测试-sysstat工具包(mpstat-主要查看CPU负载与iostat-看数据换入换出以及pidstat-主要看上下文切换)

    1.mpstat概述 mpstat (multiprocessor state) 可以查看所有cpu的平均负载,也可以查看指定cpu的负载.所以mpstat其实就是主要查看CPU负载的一个工具.是一款 ...

  3. Leecode剑指 Offer 07. 重建二叉树

    输入某二叉树的前序遍历和中序遍历的结果,请重建该二叉树.假设输入的前序遍历和中序遍历的结果中都不含重复的数字. 例如,给出 前序遍历 preorder = [3,9,20,15,7]中序遍历 inor ...

  4. Java基础__04.GUI编程

    GUI编程常见的组件: 窗口 弹窗 面板 文本框 列表框 按钮 图片 监听事件 鼠标操作 键盘事件 GUI简介 GUI的核心技术:Swing AWT,是需要jre环境的. AWT介绍 包含了很多类和接 ...

  5. 日常开发记录-Object函数的内置方法Object.entries

    方法1: const data = { id: 1, name: "张三", age: 22 } let params = "" /* Object.entri ...

  6. Python-celery介绍与快速上手

    1.celery介绍:   celery是一个基于Python开发的模块,可以帮助我们在开发过程中,对任务进行分发和处理.               详细介绍取自:Python之celery的简介与 ...

  7. beanshell脚本构造生成随机大小的文件

    文件下载地址:链接: https://pan.baidu.com/s/1wum8hfBeLMipdtQlqysp8A?pwd=8e7r 提取码: 8e7r #!/bin/bash -e # sh fi ...

  8. Windows安装MySQL5.7配置

    1.下载对应版本安装包,http://dev.mysql.com/downloads/mysql 2.将安装包解压 3.解压后会发现没有my.ini文件,此版本并不需要手动创建my.ini文件,手动创 ...

  9. idea安装破解

    转 一般都会去官网下载,官网地址IntelliJ IDEA,官网上对于不同的操作系统(windows,macOS,Linux)都有两个版本可供下载 3|0安装 确认已经安装好了 JDK ,每个IDEA ...

  10. 理解函数调用_使用argument参数

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...