1. 程式人生 > >Mybatis 代碼自動生成[myeclipse版]

Mybatis 代碼自動生成[myeclipse版]

help myeclips upd tro project blog abc mysq 表名

使用環境說明:

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

技術分享圖片

自動生成代碼:

技術分享圖片

Mybatis 代碼自動生成[myeclipse版]