1.所需的jar 包
mybatis-3.0.4.jar 、mybatis-generator-core-1.3.1.jar 、 mysql-connector-java-5.1.13.jar
mybatis下载地址:http://code.google.com/p/mybatis/
2.新建文件夹
新建文件夹E://mygen,将以上三个文件放入夹
3.同目录创建
generator.xml 文件
4.执行命令完成。
cmd ----E:-----cd E://mygen----Java -jar mybatis-generator-core-1.3.1.jar -configfile generator.xml -overwrite
mybatis-3.0.4.jar 、mybatis-generator-core-1.3.1.jar 、 mysql-connector-java-5.1.13.jar
mybatis下载地址:http://code.google.com/p/mybatis/
2.新建文件夹
新建文件夹E://mygen,将以上三个文件放入夹
3.同目录创建
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="E:\workspace10\mydemo\WebRoot\WEB-INF\lib\mysql-connector-java-5.1.13.jar" />
<context id="MYSQLTables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/renwu" userId="root" password="root">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<javaModelGenerator targetPackage="com.hc360.renwu.po" targetProject="E:\workspace10\renwu\src\main\java\com\hc360\renwu\po">
<property name="enableSubPackages" value="false" />
<property name="trimStrings" value="false" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.hc360.qiye.renwu.mapper" targetProject="E:\workspace10\renwu\src\main\java\com\hc360\renwu\dao\mapper">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.hc360.renwu.dao" targetProject="E:\workspace10\renwu\src\main\java\com\hc360\renwu\dao">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 -->
<table tableName="achievement" domainObjectName="Achievement" schema="renwu" enableInsert="true"
enableSelectByPrimaryKey="true" enableSelectByExample="false" enableDeleteByExample="false"
enableCountByExample="false" enableUpdateByExample="false">
<property name="useActualColumnNames" value="false" />
</table>
<table tableName="city" domainObjectName="City" schema="renwu" enableInsert="true"
enableSelectByPrimaryKey="true" enableSelectByExample="false" enableDeleteByExample="false"
enableCountByExample="false" enableUpdateByExample="false">
<property name="useActualColumnNames" value="false" />
</table>
</context>
</generatorConfiguration>
4.执行命令完成。
cmd ----E:-----cd E://mygen----Java -jar mybatis-generator-core-1.3.1.jar -configfile generator.xml -overwrite