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>

    开启打怪升级之旅
  • 相关阅读:
    如何对已上架的宝贝进行调整不被降权?
    报错ERR_CONNECTION_REFUSED,如何解决(原创)
    ***在Linux环境下mysql的root密码忘记解决方法(三种)-推荐第三种
    微信获取用户基本信息,头像是一张“暂时无法查看”的图?
    Linux中zip压缩和unzip解压缩命令详解
    Android必知必会-App 常用图标尺寸规范汇总
    国外主机海外主机测评总结
    美国主机BlueHost vs HostEase
    cPanel中添加设置附加域(Addon domain)
    香港新世界机房和电讯盈科机房,沙田机房,葵芳机房哪数据中心一个好?服务器托管
  • 原文地址:https://www.cnblogs.com/zhangliwei/p/7821997.html
Copyright © 2011-2022 走看看