1 下载 mybatis-generator-core-1.3.5
2 解压到 d:\
3 配置 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="D:\mysql-connector-java-5.1.26\mysql-connector-java-5.1.26-bin.jar" />
<context id="context1" >
<!-- 去掉注释 -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
<property name="suppressDate" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.20.162:3306/tsb_ischool_qingguo?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true" userId="数据库用户" password="数据库密码" />
<!-- 禁止类型强制转换 -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- 生成bean类存放位置 -->
<javaModelGenerator targetPackage="com.tsb.ischool.oauth2.bean"
targetProject="D:\work\项目名\src\main\java">
</javaModelGenerator>
<!-- 生成mapper文件存放位置 -->
<sqlMapGenerator targetPackage="com.tsb.ischool.oauth2.mapper"
targetProject="D:\work\项目名\src\main\java">
</sqlMapGenerator>
<!-- 生成Dao类存放位置 -->
<javaClientGenerator targetPackage="com.tsb.ischool.oauth2.dao"
type="XMLMAPPER" targetProject="D:\work\项目名\src\main\java">
</javaClientGenerator>
<table tableName="t_oauth_token" domainObjectName="TokenBean" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<property name="useActualColumnNames" value="false" />
</table>
<table tableName="t_oauth_app" domainObjectName="AppBean" enableCountByExample="true" enableUpdateByExample="true"
enableDeleteByExample="true"
enableSelectByExample="true" selectByExampleQueryId="true">
<property name="useActualColumnNames" value="false" />
</table>
<table tableName="t_oauth_app_ext" domainObjectName="AppExtBean" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<property name="useActualColumnNames" value="false" />
</table>
</context>
</generatorConfiguration>
4 将 mybatis-generator-core-1.3.5.jar 放到 D:\work\项目名\mybatis-generator-core-1.3.5.jar (不支持 jdk1.8,必须 1.7)
5 windows下使用命令提示进入工作目录: cd D:\work\TSB_ISCHOOL2_SERVICE_OAUTH2
6 在命令提示符下运行 java -jar mybatis-generator-core-1.3.5.jar -configfile generatorConfig.xml -overwrite
6 在命令提示符下运行 java -jar mybatis-generator-core-1.3.5.jar -configfile generatorConfig.xml -overwrite
7 mapper文件就会生成在上述 xml指定的路径,手工打开查看并再次编辑即可使用