使用eclipse插件mybatis generator來自動生成實體類及映射文件


<?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="D:\maven\repository\org\postgresql\postgresql\9.3-1103-jdbc41\postgresql-9.3-1103-jdbc41.jar" />
    <context id="context1">
        <commentGenerator>
            <property name="suppressAllComments" value="true" /><!-- 是否取消注釋 -->
            <property name="suppressDate" value="false" /> <!-- 是否生成注釋代時間戳 -->
        </commentGenerator>
        <jdbcConnection driverClass="org.postgresql.Driver"
            connectionURL="jdbc:postgresql://192.168.1.1:14132/dev" userId="userId"
            password="password" />
            
        <!-- targetPackage是目標包名,  targetProject是包所在的位置-->
        <!-- javaModelGenerator生成的是實體類,  sqlMapGenerator生成的是映射文件,  javaClientGenerator生成的是dao -->
        <javaModelGenerator targetPackage="auto.dto"
            targetProject="testProject\src\main\java" />
        <sqlMapGenerator targetPackage="auto.xml"
            targetProject="testProject\src\main\java" />
        <javaClientGenerator targetPackage="auto.dao"
            targetProject="testProject\src\main\java" type="XMLMAPPER" />
            
        <!-- domainObjectName是表對應的實體類名,  tableName是對應的表名-->
        <!-- table可以配置多個,enable*幾個參數是為了自動生成一些額外的sql操作,可以關閉-->
        <table domainObjectName="StudentInfoDto" tableName="student_info"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false">
        </table>
        <table domainObjectName="TeacherInfoDto" tableName="teacher_info"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false">
        </table>
    </context>
</generatorConfiguration>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM