MyBatis Generator 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>  
    <!-- 引入配置文件 -->  
    <properties resource="init.properties"/>  
      
    <!-- 指定數據鏈接驅動jar地址 -->  
    <classPathEntry location="${classPath}" />  
      
    <!-- 一個數據庫一個context -->  
    <context id="infoGuardian">  
        <!-- 註釋 -->  
        <commentGenerator >  
            <property name="suppressAllComments" value="false"/><!-- 是否取消註釋 -->  
            <property name="suppressDate" value="true" /> <!-- 是否生成註釋代時間戳-->  
        </commentGenerator>  
          
        <!-- jdbc鏈接 -->  
        <jdbcConnection driverClass="${jdbc_driver}"  
            connectionURL="${jdbc_url}" userId="${jdbc_user}"  
            password="${jdbc_password}" />  
          
        <!-- 類型轉換 -->  
        <javaTypeResolver>  
            <!-- 是否使用bigDecimal, false可自動轉化如下類型(Long, Integer, Short, etc.) -->  
            <property name="forceBigDecimals" value="false"/>  
        </javaTypeResolver>  
          
        <!-- 生成實體類地址 -->    
        <javaModelGenerator targetPackage="com.oop.eksp.user.model"  
            targetProject="${project}" >  
            <!-- 是否在當前路徑下新加一層schema,eg:fase路徑com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->  
            <property name="enableSubPackages" value="false"/>  
            <!-- 是否針對string類型的字段在set的時候進行trim調用 -->  
            <property name="trimStrings" value="true"/>  
        </javaModelGenerator>  
          
        <!-- 生成mapxml文件 -->  
        <sqlMapGenerator targetPackage="com.oop.eksp.user.data"  
            targetProject="${project}" >  
            <!-- 是否在當前路徑下新加一層schema,eg:fase路徑com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->  
            <property name="enableSubPackages" value="false" />  
        </sqlMapGenerator>  
          
        <!-- 生成mapxml對應client,也就是接口dao -->      
        <javaClientGenerator targetPackage="com.oop.eksp.user.data"  
            targetProject="${project}" type="XMLMAPPER" >  
            <!-- 是否在當前路徑下新加一層schema,eg:fase路徑com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->  
            <property name="enableSubPackages" value="false" />  
        </javaClientGenerator>  
          
        <!-- 配置表信息 -->      
        <table schema="${jdbc_user}" tableName="s_user"  
            domainObjectName="UserEntity" enableCountByExample="false"  
            enableDeleteByExample="false" enableSelectByExample="false"  
            enableUpdateByExample="false">  
            <!-- schema即爲數據庫名 tableName爲對應的數據庫表 domainObjectName是要生成的實體類 enable*ByExample   
                是否生成 example類   -->  
              
            <!-- 忽略列,不生成bean 字段 -->  
            <ignoreColumn column="FRED" />  
            <!-- 指定列的java數據類型 -->  
            <columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" />  
        </table>  
  
    </context>  
</generatorConfiguration>
相關文章
相關標籤/搜索