zoukankan      html  css  js  c++  java
  • mybatis-generator自动生成dao,mapping,model

    mybatis-generator下载地址:https://github.com/mybatis/generator/releases/tag/mybatis-generator-1.3.2 

    下载好后,解压:

    D:	oolsmybatis-generator-core-1.3.2lib>dir
     驱动器 D 中的卷没有标签。
     卷的序列号是 000B-8134
    
     D:	oolsmybatis-generator-core-1.3.2lib 的目录
    
    2015/10/28  14:37    <DIR>          .
    2015/10/28  14:37    <DIR>          ..
    2015/10/28  14:38             2,039 generatorConfig.xml
    2012/07/16  14:53         1,696,539 mybatis-generator-core-1.3.2-javadoc.jar
    2012/07/16  14:53           411,564 mybatis-generator-core-1.3.2-sources.jar
    2012/07/16  14:54           516,357 mybatis-generator-core-1.3.2.jar
    2014/04/09  09:17           709,922 mysql-connector-5.1.7.jar
    2015/10/28  14:39    <DIR>          src
                   5 个文件      3,336,421 字节
                   3 个目录 249,392,951,296 可用字节

    编辑好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-5.1.7.jar"/>
        <context id="DB2Tables"    targetRuntime="MyBatis3">
            <commentGenerator>
                <property name="suppressDate" value="true"/>
                <!-- 是否去除自动生成的注释 true:是 : false:否 -->
                <property name="suppressAllComments" value="true"/>
            </commentGenerator>
            <!--数据库链接URL,用户名、密码 -->
            <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/sdp_di" userId="root" password="root">
            </jdbcConnection>
            <javaTypeResolver>
                <property name="forceBigDecimals" value="false"/>
            </javaTypeResolver>
            <!-- 生成模型的包名和位置-->
            <javaModelGenerator targetPackage="com.cetc.di.secretkeydb.model" targetProject="src">
                <property name="enableSubPackages" value="true"/>
                <property name="trimStrings" value="true"/>
            </javaModelGenerator>
            <!-- 生成映射文件的包名和位置-->
            <sqlMapGenerator targetPackage="com.cetc.di.secretkeydb.mapping" targetProject="src">
                <property name="enableSubPackages" value="true"/>
            </sqlMapGenerator>
            <!-- 生成DAO的包名和位置-->
            <javaClientGenerator type="XMLMAPPER" targetPackage="com.cetc.di.secretkeydb.dao" targetProject="src">
                <property name="enableSubPackages" value="true"/>
            </javaClientGenerator>
            <!-- 要生成哪些表-->
            <table tableName="sdp_di_secretkey" domainObjectName="secretKeyDto" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="user" domainObjectName="UserDto" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            
        </context>
    </generatorConfiguration>

    执行如下命令:

    D:	oolsmybatis-generator-core-1.3.2lib>java -jar mybatis-generator-core-1.3.2
    .jar -configfile generatorConfig.xml -overwrite
    Table configuration with catalog null, schema null, and table user did not resol
    ve to any tables
    
    MyBatis Generator finished successfully, there were warnings.
    
    D:	oolsmybatis-generator-core-1.3.2lib>dir

    执行完毕后,得到如下的代码生成目录:

    image

  • 相关阅读:
    输出宽字符数组 C++
    python并发编程之多线程2------------死锁与递归锁,信号量等
    python并发编程之多线程1
    初始线程(相关理论)
    python并发编程之多进程2-------------数据共享及进程池和回调函数
    python并发编程之多进程1-----------互斥锁与进程间的通信
    Cpython支持的进程与线程
    进程理论基础
    函数嵌套复习
    python中if __name__ == '__main__'的说明
  • 原文地址:https://www.cnblogs.com/justinzhang/p/4919706.html
Copyright © 2011-2022 走看看