1,下載mybatis-generator-core-1.3.1-bundle(我要帶梯才下載回來)java
2,在lib中加入mysql-connector-java-5.1.36.jar,mybatis-3.3.0.jar,generatorConfig.xml(配置在文章後面),srcmysql
3,完成上步驟後mybatis-generator-core-1.3.1-bundle中lib目錄以下:sql
4,打開cmd 進入lib 中 執行腳本:mybatis
java -jar mybatis-generator-core-1.3.1.jar -configfile generatorConfig.xml -overwrite
5,執行成功:app
6,src中的代碼:dom
:code
generatorConfig.xml配置內容: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.36.jar"/> <context id="DB2Tables" targetRuntime="MyBatis3"> <commentGenerator> <property name="suppressDate" value="true"/> <property name="suppressAllComments" value="true"/> </commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1/gzb" userId="root" password="root"> </jdbcConnection> <javaTypeResolver> <property name="forceBigDecimals" value="false"/> </javaTypeResolver> <javaModelGenerator targetPackage="com.model" targetProject="src"> <property name="enableSubPackages" value="true"/> <property name="trimStrings" value="true"/> </javaModelGenerator> <sqlMapGenerator targetPackage="com.mapping" targetProject="src"> <property name="enableSubPackages" value="true"/> </sqlMapGenerator> <javaClientGenerator type="XMLMAPPER" targetPackage="com.Idao" targetProject="src"> <property name="enableSubPackages" value="true"/> </javaClientGenerator> <table tableName="worker" domainObjectName="Worker" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> </context> </generatorConfiguration>