數據源為H2數據庫,generatorConfiguration_h2.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>
<!--數據庫驅動-->
<!-- h2數據庫連接驅動jar包 -->
<classPathEntry location="h2-1.4.197.jar"/>
<!-- 一個數據庫一個context -->
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<!--suppressDate:**阻止**生成的注釋包含時間戳-->
<property name="suppressDate" value="true"/>
<!--suppressAllComments:**阻止**生成注釋-->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--數據庫鏈接地址賬號密碼-->
<jdbcConnection driverClass="org.h2.Driver" connectionURL="jdbc:h2:file:C:/test/h2db" userId="sa" password="">
</jdbcConnection>
<javaTypeResolver>
<!--控制是否強制DECIMAL和NUMERIC類型的字段轉換為Java類型的java.math.BigDecimal-->
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!--生成Model類存放位置-->
<javaModelGenerator targetPackage="com.test.dao.model" targetProject="src">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!--生成映射文件存放位置-->
<sqlMapGenerator targetPackage="mapper" targetProject="src">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!--生成Dao類存放位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.test.dao.mapper" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!--生成對應表及類名-->
<!--enableCountByExample指定是否生成動態(tài)查詢總條數語句(用于分頁的總條數查詢);
enableUpdateByExample指定是否生成動態(tài)修改語句(只修改對象中不為空的屬性);
...-->
<table tableName="sqlserver_collection" domainObjectName="SQLServerCollectionDo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
<!--該元素從將某些屬性默認計算的值更改為指定的值。-->
<columnOverride column="sqlserver_collection_sqlstring" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="sqlserver_collection_plugin_parm" javaType="java.lang.String" jdbcType="VARCHAR" />
</table>
<table tableName="wsstomp_collection" domainObjectName="WSStompCollectionDo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
</context>
</generatorConfiguration>
數據源為mysql數據庫,generatorConfiguration_mysql.xml文件,只需要把連接驅動jar包和數據源換掉即可
<?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.42.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:3307/server?useSSL=true" userId="edgeserver" password="123456">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!--生成Model類存放位置-->
<javaModelGenerator targetPackage="com.test.dao.model" targetProject="src">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!--生成映射文件存放位置-->
<sqlMapGenerator targetPackage="com.test.dao.mapper" targetProject="src">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!--生成Dao類存放位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.test.channel.dao" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!--生成對應表及類名-->
<table tableName="sys_widget" domainObjectName="SysWidgetDo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>