Mybatis—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>
<!-- 設定sql驅動路徑 -->
<classPathEntry location="E:\JavaWebCode\mysql-connector-java-5.1.39.jar" />
<!-- 此處指定生成針對MyBatis3的DAO -->
<context id="context1" targetRuntime="MyBatis3">
<!-- 註釋 -->
<commentGenerator>
<property name="suppressAllComments" value="true" /><!-- 是否取消註釋 -->
<property name="suppressDate" value="false" /> <!-- 是否生成註釋代時間戳 -->
</commentGenerator>
<!-- jdbc連線資訊 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/chytest"
userId="root" password="root" />
<!-- 生成model物件 -->
<javaModelGenerator targetPackage="chy.ui.testdata.model" targetProject="chyUITestData" />
<!-- 生成mapper物件 -->
<!-- <sqlMapGenerator targetPackage="com.zte.hemans.map" targetProject="ReadWriteSQLDB" /> -->
<!-- 生成DAO的類檔案以及配置檔案 -->
<javaClientGenerator targetPackage="chy.ui.testdata.dao" targetProject="chyUITestData" type="ANNOTATEDMAPPER" />
<table schema="" tableName="chytestdata" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false">
</table>
</context>
</generatorConfiguration>
第二種:生成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>
<!-- 設定sql驅動路徑 -->
<classPathEntry location="E:\JavaWebCode\mysql-connector-java-5.1.39.jar" />
<!-- 此處指定生成針對MyBatis3的DAO -->
<context id="context1" targetRuntime="MyBatis3">
<!-- 註釋 -->
<commentGenerator>
<property name="suppressAllComments" value="true" /><!-- 是否取消註釋 -->
<property name="suppressDate" value="false" /> <!-- 是否生成註釋代時間戳 -->
</commentGenerator>
<!-- jdbc連線資訊 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/chytest"
userId="root" password="root" />
<!-- 生成model物件 -->
<javaModelGenerator targetPackage="chy.ui.testdata.model" targetProject="chyUITestData" />
<!-- 生成mapper物件 -->
<sqlMapGenerator targetPackage="com.zte.hemans.map" targetProject="ReadWriteSQLDB" />
<!-- 生成DAO的類檔案以及配置檔案 -->
<javaClientGenerator targetPackage="chy.ui.testdata.dao" targetProject="chyUITestData" type="XMLMAPPER" />
<table schema="" tableName="chytestdata" enableCountByExample="false"enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false">
</table>
</context>
</generatorConfiguration>