zoukankan      html  css  js  c++  java
  • Mybatis_逆向工程

    做逆向工程需要安装mybatis generator插件。

    在Eclipse安装插件:

    1.先下载插件,插件文件夹是两个文件夹,一个是features,一个是plugins。将这两个文件夹放到Eclipse文件夹的dropins目录下

    2.重启Eclipse,new -> other 就可以看见Generator插件了:

    在config下建一个mybatis-generator.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驱动包jar路径,路径不能有中文 -->  
        <classPathEntry location="D:mysql-connector-java-5.0.8-bin.jar"/>  
    <!-- 配置数据源和生成代码所存放的位置 -->  
      <context id="context1" >  
        <!-- 注释 -->  
        <commentGenerator>  
            <property name="suppressAllComments" value="false"/><!-- 是否取消注释,true就是屏蔽注释,false就是要注释 -->  
        </commentGenerator>  
        <!-- jdbc连接 -->  
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"  
         connectionURL="jdbc:mysql://127.0.0.1:3306/mybatise"  
         userId="${jdbc.username}"  
         password="${jdbc.password}" />  
        
        <!-- 所生成的实体类的默认资源包src
            targetProject:项目名
            targetPackage:包名
        --> 
        <javaModelGenerator targetPackage="xxx.x.model" targetProject="MyFirstMybatisProject">
        </javaModelGenerator>  
    
        <!-- 所生成的SQLMap的映射文件的位置,默认资源包src -->  
        <sqlMapGenerator targetPackage="xxx.x.mapper" targetProject="MyFirstMybatisProject">
        </sqlMapGenerator>
        
        <!-- 指定对哪张表做逆向,表名schema:不用填写,其余属性是急用例子查询的生成 -->
        <table schema="" tableName="person"   
            domainObjectName="Items" enableCountByExample="false"  
            enableDeleteByExample="false" enableSelectByExample="false"  
            enableUpdateByExample="false">  
            <!-- 忽略列,不生成bean字段 -->  
    <!--         <ignoreColumn column="FRED"/> -->  
            <!-- 指定列的java数据类型 -->  
    <!--       <columnOverride column="PRICE" javaType="double" /> -->  
        </table>  
      </context>  
    </generatorConfiguration> 

    保存,然后右键mybatis-generator.xml 文件,点Generate Mybatis/IBatis Artifacts

    然后就生成了xxx.x.model和xxx.x.mapper

    xxx.x.mapper下自动生成了PersonMapper.xml,代码都生成好了

    xxx.x.model下自动生成的Person.java实体类

     逆向工程generator的xml里的table可以写多个:

        <table schema="" tableName="order"   
            domainObjectName="Items" enableCountByExample="false"  
            enableDeleteByExample="false" enableSelectByExample="false"  
            enableUpdateByExample="false">  
        </table>  
        <table schema="" tableName="order_detail"   
            domainObjectName="Items" enableCountByExample="false"  
            enableDeleteByExample="false" enableSelectByExample="false"  
            enableUpdateByExample="false">  
        </table> 
  • 相关阅读:
    Rasp技术介绍与实现(一)
    青藤云安全细述:三大云安全工具(CASB、CSPM、CWPP)的使用场景
    CWPP产品市场演进
    Global CyberSecurity Landscape
    Scala学习之路 (五)Scala的关键字Lazy
    Scala学习之路 (四)Scala的数组、映射、元组、集合
    Scala学习之路 (三)Scala的基本使用
    Scala学习之路 (二)使用IDEA开发Scala
    Scala学习之路 (一)Scala的安装
    Azkaban学习之路 (三)Azkaban的使用
  • 原文地址:https://www.cnblogs.com/lonske/p/9011461.html
Copyright © 2011-2022 走看看