pom配置
<dependency>
<groupId>org.mybatis.generator
<artifactId>mybatis-generator-core
<version>1.3.7</version>
</dependency>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.7</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</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">
-->
<classPathEntry location="D:\maven_repository\mysql\mysql-connector-java\8.0.11\mysql-connector-java-8.0.11.jar" />
<context id="msqlTables" targetRuntime="MyBatis3">
<plugin type="org.mybatis.generator.plugins.SerializablePlugin">
driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.1:3306/tongji"
userId="xxx"
password="xxx">
<property name="forceBigDecimals" value="false" />
<javaModelGenerator targetPackage="存放实体类的包名" targetProject="./src/main/java">
<property name="enableSubPackages" value="true"/>
<!-- 是否对model添加 构造函数 -->
<property name="constructorBased" value="true"/>
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true" />
<sqlMapGenerator targetPackage="mappers.csrrg" targetProject="./src/main/resources">
<property name="enableSubPackages" value="true"/>
<javaClientGenerator type="XMLMAPPER" targetPackage="存放mapper接口的包名" targetProject="./src/main/java">
<property name="enableSubPackages" value="true"/>
<!--数据库表-->
<table tableName="表名" domainObjectName="实体类的别名"
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false" >
<property name="useActualColumnNames" value="false"/>
</generatorConfiguration>
运行maven plugins 中的mybatis-generator