mybatis自動生成器生成所有表

參考:Mybatis-generator自動生成器

基於參考鏈接內容,本文描述如何自動生成所有表。(注意:所有表不包括數據庫的配置表,比如只包括oracle的SCOTT用戶中的表)

<?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">
<!-- 上面的config_1_0.dtd如果報錯,點擊該行前面的小燈泡並選擇Fetch...即可-->
<!-- 以下所有TODO是需要自定義必須改的地方 -->
<generatorConfiguration>
    <!-- TODO 數據庫驅動:選擇你的本地硬盤上面的數據庫驅動包-->
    <classPathEntry  location="D:\jars\com\oracle\ojdbc6\11.2.0.4.0\ojdbc6-11.2.0.4.0.jar"/>
    <context id="DB2Tables"  targetRuntime="MyBatis3">
        <commentGenerator>
            <property name="suppressDate" value="true"/>
            <!-- 是否去除自動生成的註釋 true:是 : false:否 -->
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <!-- TODO 數據庫鏈接URL,用戶名、密碼 -->
        <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin://127.0.0.1:1521/orcl" userId="scott" password="tiger">
        </jdbcConnection>
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>
        <!-- TODO 生成模型的包名和位置-->
        <javaModelGenerator targetPackage="com.demo.model" targetProject="src/main/java">
            <property name="enableSubPackages" value="false"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>
        <!-- 生成映射文件的包名和位置-->
        <sqlMapGenerator targetPackage="mapping" targetProject="src/main/resources">
            <property name="enableSubPackages" value="false"/>
        </sqlMapGenerator>
        <!-- TODO 生成DAO的包名和位置-->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.demo.mapper" targetProject="src/main/java">
            <property name="enableSubPackages" value="false"/>
        </javaClientGenerator>
        <!-- 要生成的表 tableName是數據庫中的表名或視圖名 domainObjectName是實體類名-->
<!--        <table tableName="dept" domainObjectName="Dept" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
		<!-- 生成數據庫中所有表的實體 (標上重點,考試要考:要加上schema=SCOTT(大寫),否則會生成所有實體表)-->
        <table tableName="%" schema="SCOTT" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>
    </context>
</generatorConfiguration>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章