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="C:/Users/Java/.m2/repository/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar"/>
<context id="my" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="false"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!-- 需要轉化的資料庫表資訊-->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://192.168.1.108:3306/m2_db?characterEncoding=UTF-8" userId="root"
password="password"/>
<!-- 需要轉化的實體資訊-->
<javaModelGenerator targetPackage="cn.com.onethird.protection.integration.entity"
targetProject="D:/666">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 需要轉化的xml檔案資訊-->
<sqlMapGenerator targetPackage="cn.com.onethird.protection.integration.xml"
targetProject="D:/666">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 需要轉化的mapper檔案資訊-->
<javaClientGenerator targetPackage="cn.com.onethird.protection.integration.mapper"
targetProject="D:/666" type="XMLMAPPER">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 多個實體表 -->
<table tableName="t_mini_orderform" domainObjectName="MiniOrderform"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
<columnRenamingRule searchString="^D_"
replaceString=""/>
</table>
<table tableName="t_mini_orderShopping" domainObjectName="MiniOrderShopping"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
<columnRenamingRule searchString="^D_"
replaceString=""/>
</table>
<table tableName="t_checkOutDayReport_info" domainObjectName="CheckOutDayReport"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
<!--<columnRenamingRule searchString="^D_"
replaceString=""/>-->
</table>
</context>
</generatorConfiguration>
關于Mybatis-Generator
https://github.com/mybatis/generator/releases
指令行進入到generatorConfig.xml所在目錄,執行指令
java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite
如果遇到報錯,一般就是引用jar問題,可以将jar包直接放到同一個目錄中
執行成功之後