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>
<!--<properties resource="dev.properties"/>-->
<context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<property name="mergeable" value="false"></property>
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="tk.mybatis.mapper.common.Mapper"/>
</plugin>
<!--测试环境,查找keys:dev-->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF8&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8"
userId="root"
password="123456">
</jdbcConnection>
<javaModelGenerator targetPackage="com.jayce.apiversion.common.entity"
targetProject="src/main/java/"/>
<sqlMapGenerator targetPackage="com.jayce.apiversion.common.dao"
targetProject="src/main/resources/"/>
<javaClientGenerator targetPackage="com.jayce.apiversion.common.dao"
targetProject="src/main/java/"
type="XMLMAPPER"/>
<table tableName="library_book" domainObjectName="LibraryBook">
<!--<property name="rootClass"
value="com.jayce.jcweb.common.book.vo.extra.LibraryBookExtra"/>-->
<generatedKey column="book_id" identity="false" sqlStatement="MySql"/>
</table>
<!--示例说明-->
<!--<table tableName="water_user_account" domainObjectName="WaterUserAccount">
<!– 继承基类 –>
<property name="rootClass" value="com.yc.cloud.water.common.base.entity.WaterBaseEntity"/>
<!– 主键设置 –>
<generatedKey column="user_account_id" identity="false" sqlStatement="MySql"/>
</table>-->
</context>
</generatorConfiguration>
pom文件关键代码
<!-- 通用mapper -->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>1.1.2</version>
</dependency>
<plugins>
<!-- 此插件用来生成通用mapper的代码 -->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<configurationFile>./src/main/resources/generatorConfig.xml</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>3.4.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>