美文网首页
mybatis-generator

mybatis-generator

作者: blotstorm | 来源:发表于2017-09-05 11:26 被阅读0次

    mybatis-generator

    下载

    mybatis-generator
    mysql-connector

    配置文件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="/home/zhangkui.zk/work/mysql-connector-java-5.1.40/mysql-connector-java-5.1.40-bin.jar"/>  
            <context id="meta" targetRuntime="MyBatis3">
            <!-- 是否去除自动生成的注释 true:是 : false:否 --> 
            <property name="suppressAllComments" value="true" />
            <!-- true使用数据库中实际的字段名字作为生成的实体类的属性名,false 字段名字转换为Camel Case风格 -->
            <property name="useActualColumnNames" value="false" />
            <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                connectionURL="jdbc:mysql://10.101.72.2:3306/test72" userId="test72"
                password="123456">
            </jdbcConnection>
    
            <javaTypeResolver>
                <property name="forceBigDecimals" value="false" />
            </javaTypeResolver>
    
            <!--生成Model类存放位置-->
            <javaModelGenerator targetPackage="com.alibaba.searchdump.hrdb.catalog.model" targetProject="src9999">
                <!-- whether add schema(mysql call database)name after targetPackage  -->
                <property name="enableSubPackages" value="true" />
                <!-- 从数据库返回的值被清理前后的空格,CHAR fields rather than VARCHAR  -->
                <property name="trimStrings" value="true" />
            </javaModelGenerator>
    
            <!-- Mapper xml映射 -->
            <sqlMapGenerator targetPackage="resources.mapper" targetProject="src9999">
                <property name="enableSubPackages" value="true" />
            </sqlMapGenerator>
    
            <!-- Mapper接口 -->
            <javaClientGenerator type="XMLMAPPER" targetPackage="com.alibaba.searchdump.hrdb.catalog.mapper" targetProject="src9999">
                <property name="enableSubPackages" value="true" />
            </javaClientGenerator>
    
            <!-- remove example-->
            <table schema="test72" tableName="t_user" domainObjectName="TuserDO" 
                enableCountByExample="false" enableUpdateByExample="false" 
                enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
    
        </context>
    
    </generatorConfiguration>
    
    

    生成Model和Mapper

    java -jar /home/zhangkui.zk/work/mybatis-generator-core-1.3.5/lib/mybatis-generator-core-1.3.5.jar -configfile generatorConfig.xml -overwrite
    

    如何使用mybatis-generator生成的example

    参考网页

    http://www.atatech.org/articles/49573
    http://generator.sturgeon.mopaas.com/
    http://www.cnblogs.com/xdp-gacl/p/4261895.html

    相关文章

      网友评论

          本文标题:mybatis-generator

          本文链接:https://www.haomeiwen.com/subject/ibdujxtx.html