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

 

自動生成代碼:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM