使用Generator 自动生成 model mapper mapping 文件
2.下载完成解压文件到任意目录
3.删除下mybatis-generator-core-1.3.2\mybatis-generator-core-1.3.2\lib\src下的所有文件
![](https://images2015.cnblogs.com/blog/988746/201706/988746-20170601151636618-1815829784.png)
4.修改配置文件 mybatis-generator-core-1.3.2\mybatis-generator-core-1.3.2\lib\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>
<!-- 数据库驱动-->
<classPathEntry location="mysql-connector-java-5.1.25-bin.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/generator" userId="root" password="249832">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="test.domain" targetProject="src">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件的包名和位置-->
<sqlMapGenerator targetPackage="test.mapping" targetProject="src">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="test.IDao" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<table tableName="test" domainObjectName="Test" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
![](https://images2015.cnblogs.com/blog/988746/201706/988746-20170601151748446-171232820.png)
5.使用cmd 进入所在目录 cd C:\Users\fxl\Desktop\mybatis-generator-core-1.3.2\mybatis-generator-core-1.3.2\lib\src
![](https://images2015.cnblogs.com/blog/988746/201706/988746-20170601151834243-822664663.png)
输入命令 java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite
![](https://images2015.cnblogs.com/blog/988746/201706/988746-20170601151915383-636268981.png)
6.生成完成 到lib目录下找到指定文件即可
![](https://images2015.cnblogs.com/blog/988746/201706/988746-20170601151944289-947846626.png)