zoukankan      html  css  js  c++  java
  • Mybatis-Generator自动生成XML文件以及接口和实体类

    整合了MySQL和Oracle配置文件生成方法

    这个是整个文件夹的下载地址:http://www.codepeople.cn/download

    主要给大家介绍一下generatorConfig.xml文件的配置,以及生成后的文件。

    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>
        <!--数据库驱动-->
        <classPathEntry    location="mysql-connector-java-8.0.11.jar"/>
        <context id="DB2Tables"    targetRuntime="MyBatis3">
            <commentGenerator>
                <property name="suppressDate" value="true"/>
                <property name="suppressAllComments" value="true"/>
            </commentGenerator>
            <!--数据库链接地址账号密码,主要Mysql版本,高版本的Mysql要加上时区-->
            <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/seezoon-framework?serverTimezone=GMT%2B8" userId="root" password="root">
            </jdbcConnection>
            <javaTypeResolver>
                <property name="forceBigDecimals" value="false"/>
            </javaTypeResolver>
            <!--生成Model类存放位置-->
            <javaModelGenerator targetPackage="lcw.model" targetProject="src">
                <property name="enableSubPackages" value="true"/>
                <property name="trimStrings" value="true"/>
            </javaModelGenerator>
            <!--生成映射文件存放位置-->
            <sqlMapGenerator targetPackage="lcw.mapping" targetProject="src">
                <property name="enableSubPackages" value="true"/>
            </sqlMapGenerator>
            <!--生成Dao类存放位置-->
            <javaClientGenerator type="XMLMAPPER" targetPackage="lcw.dao" targetProject="src">
                <property name="enableSubPackages" value="true"/>
            </javaClientGenerator>
            <!--生成对应表及类名enableCountByExample设置为false的意思就是xml中不生成这个方法和接口-->
            <table tableName="sys_dept" domainObjectName="SysDept" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="sys_user" domainObjectName="SysUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
        </context>
    </generatorConfiguration>

    然后在cmd命令行下进入到Mybatis-Generator所在的目录,然后执行命令:

    java -jar mybatis-generator-core-1.3.7.jar -configfile generatorConfig.xml -overwrite

    然后生成文件在src目录下,可自行查看。

  • 相关阅读:
    自己定义九宫格手势解锁
    2015程序猴的总结:不破楼兰终不还!
    Codeforces Round #402 (Div. 2)
    [整体二分]【学习笔记】【更新中】
    BZOJ 3110: [Zjoi2013]K大数查询 [整体二分]
    BZOJ 2738: 矩阵乘法 [整体二分]
    BZOJ 2527: [Poi2011]Meteors [整体二分]
    [偏序关系与CDQ分治]【学习笔记】
    BZOJ 2244: [SDOI2011]拦截导弹 [CDQ分治 树状数组]
    COGS 2479. [HZOI 2016]偏序 [CDQ分治套CDQ分治 四维偏序]
  • 原文地址:https://www.cnblogs.com/lr393993507/p/9565768.html
Copyright © 2011-2022 走看看