Mapper文件自动生成
<?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="D:\apache-maven-3.2.5\.m2\repository\mysql\mysql-connector-java\5.1.22\mysql-connector-java-5.1.22.jar" />
<context id="mysqlgenerator" targetRuntime="MyBatis3">
<!-- 防止生成的代码中有很多注释,加入下面的配置控制 -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
<property name="suppressDate" value="true" />
</commentGenerator>
<!-- 数据库连接 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:MySql://192.168.35.91:3358/tfaces?characterEncoding=UTF-8"
userId="root"
password="root123456">
</jdbcConnection>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- 数据表对应的model层 -->
<javaModelGenerator targetPackage="com.jd.tfaces.model.subscription" targetProject="../tfaces-model/src/main/java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- sql mapper 映射配置文件 -->
<sqlMapGenerator targetPackage="mapping.subscription" targetProject="../tfaces-web/src/main/resources">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<!-- mybatis3中的mapper接口 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.jd.tfaces.dao.subscription" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- 数据表进行生成操作 schema:相当于库名; tableName:表名; domainObjectName:对应的DO 多个表配多个即可-->
<table schema="dataRt" tableName="t_subscribe_info"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table schema="dataRt" tableName="t_subscribe_log"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
</context>
</generatorConfiguration>
引入依赖包
<plugin>
<groupId>com.jd.maven.plugins</groupId>
<artifactId>generator-maven-plugin</artifactId>
<version>1.5</version>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
maven配置
mybatis-generator:generate -e
https://blog.****.net/wangxy799/article/details/60870361