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

    自动生成代码:

  • 相关阅读:
    HTTP 常见状态码
    SpringMVC 入门
    Maven 整合SSH框架
    SSH 框架整合总结
    Maven 整合SSH框架之pom.xml
    Maven 入门
    WebService 综合案例
    CXF 框架
    jQuery高级
    JavaScript补充:BOM(浏览器对象模型)
  • 原文地址:https://www.cnblogs.com/orac/p/8456744.html
Copyright © 2011-2022 走看看