zoukankan      html  css  js  c++  java
  • Mybatis 代码自动生成[myeclipse版]

     使用环境说明:

    OS:windows 7 64位

    myeclipse: 2017 CI

    1.安装

    打开myeclipse--help---Install from catalog--选择eclipse应用市场---Find中填入 Mybatis (注意:区分大小写) 点go 搜索出

    Mybatis Generator  选择安装.  关闭myeclipse 重新打开.

    2.使用

    在你的项目中创建一个 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>
      <context id="context1">
        <!-- 数据库信息 -->
        <jdbcConnection connectionURL="jdbc:mysql://127.0.1.1/kanna" 
        driverClass="com.mysql.jdbc.Driver" 
        password="abc123456" userId="root" />    
        
        
        <javaModelGenerator targetPackage="org.mykanna.school.entity" targetProject="kanna/src/main/java" />
        
          <sqlMapGenerator targetPackage="org.mykanna.mapper" targetProject="kanna/src/main/resources" />  
          
          <javaClientGenerator targetPackage="org.mykanna.school.dao" targetProject="kanna/src/main/java" type="XMLMAPPER" />
    
        <!-- 
        生成表并且不生成example   
        tableName:表名
        domainObjectName:对象名
        -->
        <table tableName="tb_user" domainObjectName="User" 
        enableCountByExample="false" enableUpdateByExample="false" 
        enableDeleteByExample="false" enableSelectByExample="false" 
        selectByExampleQueryId="false">
        </table>  
        
      </context>
    </generatorConfiguration>

     xml 右键---run as---run Mybatis Generator

    自动生成代码:

  • 相关阅读:
    广域网(ppp协议、HDLC协议)
    0120. Triangle (M)
    0589. N-ary Tree Preorder Traversal (E)
    0377. Combination Sum IV (M)
    1074. Number of Submatrices That Sum to Target (H)
    1209. Remove All Adjacent Duplicates in String II (M)
    0509. Fibonacci Number (E)
    0086. Partition List (M)
    0667. Beautiful Arrangement II (M)
    1302. Deepest Leaves Sum (M)
  • 原文地址:https://www.cnblogs.com/orac/p/8456744.html
Copyright © 2011-2022 走看看