zoukankan      html  css  js  c++  java
  • mybatis generator--逆向工程工具的使用

    先附上官方网址:http://www.mybatis.org/generator/

    Mybatis属于半自动ORM,在使用这个框架中,工作量最大的就是书写Mapping的映射文件,由于手动书写很容易出错,我们可以利用Mybatis-Generator来帮我们自动生成文件。

    其次,mybatis generator 只适用于单表查询。mybatis-gennerator插件自动生成mybatis所需要的dao、bean、mapper xml文件,能够极大的提升工作效率,几乎不用再自己写sql语句,实现项目中的增删改查。

    主要介绍在oracel数据库中,配置文件的书写。

    <?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:j2eeidejdbclibojdbc7.jar" />-->
    <context id="context1" targetRuntime="MyBatis3">
    <!-- 禁用mybatis插件自动生成的注释 -->
    <commentGenerator>
    <property name="suppressDate" value="true" />
    <property name="suppressAllComments" value="true" />
    </commentGenerator>

    <!-- 数据库连接串配置 -->
    <jdbcConnection
    connectionURL="jdbc:oracle:thin:@ip:端口:chnldevn"
    driverClass="oracle.jdbc.driver.OracleDriver"
    password="userName" userId="password" />

    <!-- 类型转换器 -->
    <javaTypeResolver type="org.mybatis.generator.internal.types.JavaTypeResolver4MvneImpl">
    <!--
    true:使用BigDecimal对应DECIMAL和 NUMERIC数据类型
    false:默认,
    scale>0;length>18:使用BigDecimal;
    scale=0;length[10,18]:使用Long;
    scale=0;length[5,9]:使用Integer;
    scale=0;length<5:使用Short;
    -->
    <property name="forceBigDecimals" value="false"/>
    </javaTypeResolver>

    <!-- java实体类配置 -->
    <javaModelGenerator
    targetPackage="com.ai.channel.mgmt.dao.mapper.bo"
    targetProject="chan-srv-mgmt-core/src/main/java" />

    <!-- sqlMap映射xml配置 -->
    <sqlMapGenerator
    targetPackage="mybatis.mapper"
    targetProject="chan-srv-mgmt-core/src/main/resources" />
    <!-- mybatis接口类配置 -->
    <javaClientGenerator
    targetPackage="com.ai.channel.mgmt.dao.mapper.interfaces"
    targetProject="chan-srv-mgmt-core/src/main/java"
    type="XMLMAPPER" />

    <table tableName="MGMT_CHL_PHYSICAL" enableCountByExample="true"
    enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
    selectByExampleQueryId="true"/>

    <table tableName="MGMT_CHL_PHYSICAL_HIS" enableCountByExample="true"
    enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
    selectByExampleQueryId="true"/>

    <table tableName="MGMT_BAS_DECORATION_TEMPL" enableCountByExample="true"
    enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
    selectByExampleQueryId="true"/>

    <table tableName="MGMT_CHL_DECORATION" enableCountByExample="true"
    enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
    selectByExampleQueryId="true"/>
    <table tableName="MGMT_CHL_DECORATION_HIS" enableCountByExample="true"
    enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
    selectByExampleQueryId="true"/>

    </context>
    </generatorConfiguration>

    开启打怪升级之旅
  • 相关阅读:
    002 下载文件
    001 okhttp3的POST使用
    000 okhttp3的Get使用
    008 webpack的其他使用方式
    007 webpack基本的用法
    three.js 3d三维网页代码加密的实现方法
    物联网开发技术栈
    9个顶级开发IoT项目的开源物联网平台
    hibernate缓存机制详细分析
    机器学习大牛最常用的5个回归损失函数,你知道几个?
  • 原文地址:https://www.cnblogs.com/zhangliwei/p/7821997.html
Copyright © 2011-2022 走看看