zoukankan      html  css  js  c++  java
  • 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> 
  • 相关阅读:
    轻重搭配
    EF的优缺点
    使用bootstrap-select有时显示“Nothing selected”
    IIS发布 HTTP 错误 500.21
    js添加的元素无法触发click事件
    sql server查看表是否死锁
    sql server把一个库表的某个字段更新到另一张表的相同字段
    SQLSERVER排查CPU占用高的情况
    SQL server中如何按照某一字段中的分割符将记录拆成多条
    LINQ to Entities does not recognize the method 'System.DateTime AddDays(Double)' method, and this method cannot be translated into a store expression.
  • 原文地址:https://www.cnblogs.com/lucky1024/p/11264071.html
Copyright © 2011-2022 走看看