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目录下,可自行查看。

  • 相关阅读:
    数组中出现次数超过一半的数字
    Trie字典树算法
    字符串匹配算法 之 基于DFA(确定性有限自动机)
    实现栈最小元素的min函数
    有关有环链表的问题
    浅谈C中的malloc和free
    undefined reference to 'pthread_create'问题解决
    用两个栈实现队列
    resf规范
    单例模式
  • 原文地址:https://www.cnblogs.com/lr393993507/p/9565768.html
Copyright © 2011-2022 走看看