一、Maven配置文件中添加如下依赖

<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
</dependency>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.4</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
</dependencies>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
<configurationFile>${basedir}/src/main/resources/generatorConfig.xml</configurationFile>
</configuration>
</plugin>

二、添加generatorConfig.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 >
<!-- mysql jar 文件位置 -->
<classPathEntry location="F:/instrument\maven/.m2/repository/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar" />
<context id="store" targetRuntime="MyBatis3">
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
<!-- 是否去除所有自动生成的文件的时间戳,默认为false -->
<!-- <property name="suppressDate" value="false"/> -->
</commentGenerator>
<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/g"
userId="root"
password="root">
<!--<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://112.35.82.91:3360/benevolenceParking"
userId="renrenbang"
password="05377975333">-->
</jdbcConnection>
<!-- targetPackage:包名称(自定义) targetProject:项目路径(自定义) -->
<javaModelGenerator targetPackage="com.zblx.park.po" targetProject="src/main/java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- 配置生成相应的实体Mapper.xml,对于Mapper3.X我们需要把type="XMLMAPPER" -->
<!-- targetPackage:包名称(自定义) targetProject:项目路径(自定义) -->
<sqlMapGenerator targetPackage="com.zblx.park.mapper" targetProject="src/main/java">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!-- 配置生成相应的接口类,对应与Mapper.xml中的一系列CRUD方法SQL语句 -->
<!-- targetPackage:包名称(自定义) targetProject:项目路径(自定义) -->
<javaClientGenerator targetPackage="com.zblx.park.dao" targetProject="src/main/java" type="XMLMAPPER">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!-- 用户表-->
<!--<table schema="benevolenceParking" tableName="parking" domainObjectName="Parking"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
>-->
<table schema="fruit" tableName="parking" domainObjectName="Parking"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
/>
<table schema="fruit" tableName="orders" domainObjectName="Orders"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
>
</table>
<table schema="fruit" tableName="car" domainObjectName="Car"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
>
</table>
<table schema="fruit" tableName="carlock" domainObjectName="CarLock"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
>
</table>
</context>
</generatorConfiguration>

SpringBoot环境中使用MyBatis代码生成工具的更多相关文章

  1. 第二章 Mybatis代码生成工具

    1.mybatis-generator作用 1).生成pojo 与 数据库结构对应 2).如果有主键,能匹配主键 3).如果没有主键,可以用其他字段去匹配 4).动态select,update,del ...

  2. mybatis实战教程(mybatis in action)之九:mybatis 代码生成工具的使用

    mybatis 应用程序,需要大量的配置文件,对于一个成百上千的数据库表来说,完全手工配置,这是一个很恐怖的工作量. 所以mybatis 官方也推出了一个mybatis代码生成工具的jar包. 今天花 ...

  3. mybatis实战教程(mybatis in action)之九:mybatis 代码生成工具的使用

    mybatis 应用程序,需要大量的配置文件,对于一个成百上千的数据库表来说,完全手工配置,这是一个很恐怖的工作量. 所以mybatis 官方也推出了一个mybatis代码生成工具的jar包. 今天花 ...

  4. Windows环境中,通过Charles工具,抓取安卓手机、苹果手机中APP应用的http、https请求包信息

    Windows环境中,通过Charles工具,抓取安卓手机.苹果手机中APP应用的http.https请求包信息1.抓取安卓手机中APP应用的http请求包信息1)在电脑上操作,查看Windows机器 ...

  5. SpringBoot项目中,Mybatis的使用

    项目中使用MyBatis的地方很少,可以说是基本不用,慕课网上面这个项目介绍给也就是一些比较简单的使用例子,我用JPA比较的多,MyBatis有两种使用方式 1.导入MyBatis的依赖 <de ...

  6. MyBatis代码生成工具mybatis-generator在Myeclipse10中的使用

    一.在MyEclipse安装目录下新建myPlugin目录,如下图所示: 二.将 mybatis.zip 里面的文件放在MyEclipse的dropins目录下,如下图所示: 三.在Myeclipse ...

  7. Android开发环境中的概念和工具介绍

    最近学习Android开发,以前使用C/C++多一些,现在再补点Java知识,不管是哪种语言,都不过是一种工具而已,真的学起来,大同小异,无谓优劣.学习Android编程肯定是要先从环境搭建开始,无论 ...

  8. 在springboot项目中使用mybatis 集成 Sharding-JDBC

    前段时间写了篇如何使用Sharding-JDBC进行分库分表的例子,相信能够感受到Sharding-JDBC的强大了,而且使用配置都非常干净.官方支持的功能还包括读写分离.分布式主键.强制路由等.这里 ...

  9. SpringBoot学习- 11、更好用的代码生成工具EasyCode

    SpringBoot学习足迹 之前的mybatis代码生成工具无法自定义模板,找了一个可以自定义模板的插件,初学者最好用比较齐全的代码生成工具,不然拼错一个代码会掉坑里半天爬不出来. 有的同学会说干么 ...

随机推荐

  1. 「JLOI2011」「LuoguP4568」飞行路线(分层图最短路

    题目描述 Alice和Bob现在要乘飞机旅行,他们选择了一家相对便宜的航空公司.该航空公司一共在nn个城市设有业务,设这些城市分别标记为00到n-1n−1,一共有mm种航线,每种航线连接两个城市,并且 ...

  2. 51nod 1218 最长递增子序列 V2——LIS+思路(套路)

    题目:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1218 自己怎么连这种 喜闻乐见的大水题 都做不出来了…… 好像见过 ...

  3. 洛谷P2024食物链——并查集补集的灵活运用

    题目:https://www.luogu.org/problemnew/show/P2024 自己在做本题时最大的障碍就是:不会在一个集合的father改变时把相应的补集也跟着改变. 借鉴题解后,才明 ...

  4. PowerShell自动部署网站—(1)、安装IIS[添加角色和角色服务]

    #------添加角色/角色服务------ Import-Module servermanager $features = get-windowsfeature Net-*,Telnet-*,Web ...

  5. POJ2887(块状链表)

    Big String Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 6346   Accepted: 1525 Descr ...

  6. web.xml中:<context-param>与<init-param>的区别与作用及获取方法

    <context-param>的作用: web.xml的配置中<context-param>配置作用1. 启动一个WEB项目的时候,容器(如:Tomcat)会去读它的配置文件w ...

  7. css水平居中方式

    1. text-align:center 这种方式只适合于内联元素或者文字处于块元素当中是,给块元素设置这个,那么块元素当中的文字或者内联元素则居中.兼容各种浏览器 <div class=&qu ...

  8. socket函数的使用方法(参数详解)

    socket函数的使用方法如下: int socket(int domain, int type, int protocol); 在参数表中,domain指定使用何种的地址类型,比较常用的有: PF_ ...

  9. ShellExecute

    有三个API函数可以运行可执行文件WinExec.ShellExecute和CreateProcess. 1.CreateProcess因为使用复杂,比较少用. 2.WinExec主要运行EXE文件. ...

  10. 2017-9-22 NOIP模拟赛[xxy][数论]

    XXY 的 的 NOIP 模拟赛 4 4 —— 数学专场 A Description定义 f(x)表示 x 的约数和,例:f(12)=1+2+3+4+6+12=28给出 x,y,求Σf(i),i∈[x ...