• Mybatis 逆向工程


    使用generatorConfig.xml 逆向生成 entity、dao、mapping

    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>    
        <!-- mysql-connector文件路径 --> 
        <!-- 引入mysql-connector-java-5.1.25.jar位置 --> 
        <classPathEntry  location="mysql-connector-java-5.1.25-bin.jar"/>    
         <!-- 是否去除自动生成的注释 true:是 : false:否 -->
        <context id="DB2Tables"  targetRuntime="MyBatis3">    
            <commentGenerator>    
                <property name="suppressDate" value="true"/>    
    
                <property name="suppressAllComments" value="true"/>    
            </commentGenerator>    
            <!-- mysql数据库连接-->  
            <jdbcConnection driverClass="com.mysql.jdbc.Driver"   
            connectionURL="jdbc:mysql://127.0.0.1:3306/dream_db"   
            userId="root" password="root">    
            </jdbcConnection>    
            <javaTypeResolver>    
                <property name="forceBigDecimals" value="false"/>    
            </javaTypeResolver>    
            <!-- 生成实体类的路径,com.entity 这个路径可以自动生成,但是必须有src这个路径 可以是具体的路径,
    例如:"E:workspacemaven_testsrcmainjava"--> 
     
            <javaModelGenerator targetPackage="com.entity"   
            targetProject="src">    
                <property name="enableSubPackages" value="true"/>
                <!-- 从数据库返回的值被清理前后的空格  -->
                <property name="trimStrings" value="true"/>    
            </javaModelGenerator>    
    
           <!-- 生成映射的路径,这个路径可以自动生成,但是必须有src这个路径-->  
           <sqlMapGenerator targetPackage="com.mapping" targetProject="src">    
                <property name="enableSubPackages" value="true"/>    
            </sqlMapGenerator>   
     
               <!-- 生成接口的路径,这个路径可以自动生成,但是必须有src这个路径-->  
            <javaClientGenerator type="XMLMAPPER" targetPackage="com.dao"   
            targetProject="src">    
                <property name="enableSubPackages" value="true"/>    
            </javaClientGenerator>    
    
            <!-- 生成数据库表对应的实体类,tableName对应数据库表名,domainObjectName对应的是将要生成的实体类名 -->
            <table tableName="user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="user_info" domainObjectName="UserInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="resource" domainObjectName="Resource" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="user_content" domainObjectName="UserContent" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="comment" domainObjectName="Comment" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="login_log" domainObjectName="LoginLog" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="role" domainObjectName="Role" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="role_resource" domainObjectName="RoleResource" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="role_user" domainObjectName="RoleUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="upvote" domainObjectName="Upvote" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
        </context>    
    </generatorConfiguration> 
  • 相关阅读:
    Lucene学习总结之七:Lucene搜索过程解析 2014-06-25 14:23 863人阅读 评论(1) 收藏
    Lucene学习总结之五:Lucene段合并(merge)过程分析 2014-06-25 14:20 537人阅读 评论(0) 收藏
    Lucene学习总结之六:Lucene打分公式的数学推导 2014-06-25 14:20 384人阅读 评论(0) 收藏
    Lucene学习总结之四:Lucene索引过程分析 2014-06-25 14:18 884人阅读 评论(0) 收藏
    Lucene学习总结之三:Lucene的索引文件格式(1) 2014-06-25 14:15 1124人阅读 评论(0) 收藏
    Lucene学习总结之二:Lucene的总体架构 2014-06-25 14:12 622人阅读 评论(0) 收藏
    Lucene学习总结之一:全文检索的基本原理 2014-06-25 14:11 666人阅读 评论(0) 收藏
    解决Eclipse中文乱码 分类: B1_JAVA 2014-06-25 11:23 336人阅读 评论(0) 收藏
    【Lucene4.8教程之五】Luke 2014-06-24 15:12 1092人阅读 评论(0) 收藏
    【Tika基础教程之一】Tika基础教程
  • 原文地址:https://www.cnblogs.com/lucky1024/p/11264071.html
Copyright © 2020-2023  润新知