generator.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:\software\lib\mysql-connector-java-5.1.21.jar" /> -->
<classPathEntry location="D:\tools\mysql-connector-java\mysql6.0.jar" />
<context id="DB2Tables" targetRuntime="MyBatis3">
<!-- 抑制警告 -->
<property name="suppressTypeWarnings" value="true" />
<!-- generate entity时,生成hashcode和equals方法 -->
<plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" />
<!-- generate entity时,生成serialVersionUID -->
<plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!-- 数据库链接URL、用户名、密码 -->
<!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/sy" userId="sypro" password="sypro"> -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test" userId="root" password="root">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- 生成模型的包名和位置 -->
<javaModelGenerator targetPackage="myproject.model" targetProject="D:\workspace\generator\src">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- 生成的映射文件包名和位置 -->
<sqlMapGenerator targetPackage="myproject.mapping" targetProject="D:\workspace\generator\src">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<!-- 生成DAO的包名和位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="myproject.dao" targetProject="D:\workspace\generator\src">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- 要生成那些表(更改tableName和domainObjectName就可以) ,由于表text类型的字段会造成单独生成一个XXXXWithBlobs类,加个columnOverride转换下
-->
<table tableName="trade" domainObjectName="Trade" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
<columnOverride column="attribute" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="remark" javaType="java.lang.String" jdbcType="VARCHAR" /> </table>
<table tableName="customer_bank" domainObjectName="CustomerBank" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="trade_extend" domainObjectName="TradeExtend" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
<columnOverride column="responsibility_info_json" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="bank_payinfo" javaType="java.lang.String" jdbcType="VARCHAR" /></table>
</context>
</generatorConfiguration>
生成语句:java -jar mybatis-generator-core-1.3.2.jar -configfile generator.xml -overwrite。
mybatis-generator-core-1.3.2.jar下载地址:http://download.youkuaiyun.com/download/varose/9790213
shift+ctrl+右击,复制粘贴生成语句。