mybatis 生成映射文件generatorConfig.xml配置

首先建立java工程:generatorJava

<?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>  
      
    <!-- 指定数据连接驱动jar地址 -->  
    <classPathEntry location="D:/workspace/ssmy/WebContent/WEB-INF/lib/ojdbc6.jar" />  
      
    <!-- 一个数据库一个context -->  
    <context id="infoGuardian">  
        <!-- 注释 -->  
        <commentGenerator >  
            <property name="suppressAllComments" value="false"/><!-- 是否取消注释 -->  
            <property name="suppressDate" value="true" /> <!-- 是否生成注释代时间戳-->  
        </commentGenerator>  
          
        <!-- jdbc连接 -->  
        <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"  
            connectionURL="jdbc:oracle:thin:@localhost:1521:orcl"
            userId="myoracle"  
            password="tiger" />  
          
        <!-- 类型转换 -->  
        <javaTypeResolver>  
            <!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->  
            <property name="forceBigDecimals" value="false"/>  
        </javaTypeResolver>  
          
        <!-- 生成实体类地址 -->    
        <javaModelGenerator targetPackage="ssmy.com.entity"  
            targetProject="ssmy" >  
            <!-- 是否在当前路径下新加一层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="ssmy.com.mapper"  
            targetProject="ssmy" >  
            <!-- 是否在当前路径下新加一层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="ssmy.com.dao"  
            targetProject="ssmy" 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="myoracle" tableName="t_credit"  
            domainObjectName="CreditEntity" 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>  
       <table schema="myoracle" tableName="NEWS_USER"  
            domainObjectName="NewsUserEntity" 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>
va
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值