zoukankan      html  css  js  c++  java
  • mybatis总结

    mybatis生成器下载地址:

    https://github.com/mybatis/generator/releases/tag/mybatis-generator-1.3.6

     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:数据库的JDBC驱动的jar包地址 -->
         <classPathEntry location="D:workspacesqlGernaratorlibmysql-connector-java-5.1.28-bin.jar" />
    
        <context id="caigouTables" targetRuntime="MyBatis3">
            <commentGenerator>
                <!-- 是否去除自动生成的注释 true:是 : false:否 -->
                <property name="suppressAllComments" value="true" />
            </commentGenerator>
            <!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
            <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                connectionURL="jdbc:mysql://localhost:3306/tmall" userId="root"
                password="root">
            </jdbcConnection> 
            <!-- <jdbcConnection driverClass="oracle.jdbc.OracleDriver"
                connectionURL="jdbc:oracle:thin:@127.0.0.1:1521:tmall" 
                userId="tmall"
                password="tmall">
            </jdbcConnection> -->
    
            <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL 和 
                NUMERIC 类型解析为java.math.BigDecimal -->
            <javaTypeResolver>
                <property name="forceBigDecimals" value="false" />
            </javaTypeResolver>
    
            <!-- targetProject:生成PO类的位置 -->
            <javaModelGenerator targetPackage="tdtk.domain"
                targetProject=".src">
                <!-- enableSubPackages:是否让schema作为包的后缀 -->
                <property name="enableSubPackages" value="true" />
                <!-- 从数据库返回的值被清理前后的空格 -->
                <property name="trimStrings" value="true" />
            </javaModelGenerator>
            <!-- targetProject:自动mapper的位置 -->
            <sqlMapGenerator targetPackage="tdtk.dao" 
                targetProject=".src">
                <property name="enableSubPackages" value="false" />
            </sqlMapGenerator>
    
            <javaClientGenerator type="XMLMAPPER"
                targetPackage="tdtk.dao" implementationPackage="tdtk.dao"
                targetProject=".src">
                <property name="enableSubPackages" value="false" />
            </javaClientGenerator>
            
        
            <table tableName="Product" domainObjectName="Product" 
            enableCountByExample="false" enableUpdateByExample="false" 
            enableDeleteByExample="false" enableSelectByExample="false" 
            selectByExampleQueryId="false"/>
            
    
        </context>
    </generatorConfiguration>

     执行生成:

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

    jsr303验证:

    https://www.imooc.com/article/details/id/19844

  • 相关阅读:
    linux系统日志使用
    C# progressbar 用法
    python 新时代
    linux 常用命令 集锦
    c# DirectoryInfo类 详解
    哈佛(转)
    寒门难再出贵子
    排序算法
    JavaScript弹出框
    js中innerHTML与innerText的用法与区别
  • 原文地址:https://www.cnblogs.com/gaogaoyanjiu/p/8709269.html
Copyright © 2011-2022 走看看