1.首先下載Jar包
傳送門:鏈接:http://pan.baidu.com/s/1pKUxOX9 密碼:9q8y
2.在mybatis-generator-core-1.3.2.jar包同級(jí)創(chuàng)建目錄·src
·用以存放文件
3.創(chuàng)建配置文件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>
<!-- 數(shù)據(jù)庫驅(qū)動(dòng)位置 -->
<classPathEntry location="E:\mybatis-generator-core-1.3.1\mysql-connector-java-5.0.8-bin.jar" />
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!-- 數(shù)據(jù)庫的url卸奉、用戶名仰泻、密碼 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/dbo" userId="root" password="123456">
</jdbcConnection>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- 生成模型的包名和位置 -->
<javaModelGenerator targetPackage="com.paywing.domain" targetProject="E:\mybatis-generator-core-1.3.1\src">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- 生成的映射文件包名和位置 -->
<sqlMapGenerator targetPackage="com.paywing.mapping" targetProject="E:\mybatis-generator-core-1.3.1\src">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<!-- 生成DAO的包名和位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.paywing.dao" targetProject="E:\mybatis-generator-core-1.3.1\src">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- 生成那些表 tableName表名热康,domainObjectName應(yīng)于數(shù)據(jù)庫表的javaBean類名-->
<table tableName="tb_bookinfo" domainObjectName="TB_BookInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
<table tableName="tb_booktype" domainObjectName="TB_Booktype" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
</context>
</generatorConfiguration>
4.執(zhí)行命令
E:\>java -jar F:\mybatis-generator-core-1.3.1.jar -configfile F:\generator.xml -overwrite