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

    自动生成代码:

  • 相关阅读:
    BZOJ1029:[JSOI2007]建筑抢修(贪心,堆)
    1054. [HAOI2008]移动玩具【BFS】
    1297. [SCOI2009]迷路【矩阵乘法】
    1192. [HNOI2006]鬼谷子的钱袋【进制】
    2243. [SDOI2011]染色【树链剖分】
    1051. [HAOI2006]受欢迎的牛【强连通分量】
    codevs 2074 营救 WW
    codevs 1191 数轴染色
    codevs 2855 游乐园的迷宫 bfs
    codevs 2806 红与黑
  • 原文地址:https://www.cnblogs.com/orac/p/8456744.html
Copyright © 2011-2022 走看看