新聞中心
iBATIS for Eclipse設(shè)置問(wèn)題我們要從頭說(shuō)起,對(duì)于IBatis應(yīng)用最煩人的重復(fù)工作就是不停的寫(xiě)DAO,DTO,和xml文件里面的sqlmap,其實(shí)很多時(shí)候這些工作是重復(fù)而且無(wú)聊的。好在我們還有abator (http://ibatis.apache.org/abator.html ),一個(gè)IBatis自動(dòng)生成工具,他可以幫助你生成大量的DAO,DTO和sqlmap。

創(chuàng)新互聯(lián)建站專(zhuān)注于東川企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站設(shè)計(jì),購(gòu)物商城網(wǎng)站建設(shè)。東川網(wǎng)站建設(shè)公司,為東川等地區(qū)提供建站服務(wù)。全流程按需求定制開(kāi)發(fā),專(zhuān)業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)建站專(zhuān)業(yè)和態(tài)度為您提供的服務(wù)
如果你使用Eclipse作為IDE那么事情就很簡(jiǎn)單了(相信沒(méi)有幾個(gè)人不在用):
安裝Eclipse插件
1. 要求eclipse3.1,jdk1.4以上
2. 在Eclipse上安裝abator插件
Eclipse菜單欄 --﹥ help --﹥ Software Updates --﹥ Find And Install...
在彈出的對(duì)話框中選擇 “Search for new features to install” 然后點(diǎn)擊 “next”
在對(duì)話框中點(diǎn)擊按鈕 New Remort Site... 在彈出的對(duì)話框中的URL輸入框中填寫(xiě) http://ibatis.apache.org/tools/abator ,Name輸入框就隨便寫(xiě)些什么了。
點(diǎn)擊Finish,安裝插件,然后重新啟動(dòng)Eclipse
下面測(cè)試一下功能
1. 新建一個(gè)java工程
2. 在Eclipse菜單欄中興建一個(gè) abator 配置文件
File --﹥ Abator for iBatis Configration File
好的,我們完成了創(chuàng)建配置文件,下面打abator配置文件,看看里面怎么去配置
打開(kāi)后內(nèi)容基本上是這樣
xml 代碼
- ?xml v﹤ersion="1.0" encoding="UTF-8"?﹥
- ﹤!DOCTYPE abatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN"
- "http://ibatis.apache.org/dtd/abator-config_1_0.dtd"﹥
- ﹤abatorConfiguration﹥
- ﹤abatorContext﹥﹤!-- TODO: Add Database Connection Information --﹥
- ﹤jdbcConnection driverClass="???"
- connectionURL="???"
- userId="???"
- password="???"﹥
- ﹤classPathEntry location="???" /﹥
- ﹤/jdbcConnection﹥
- ﹤javaModelGenerator targetPackage="???" targetProject="???" /﹥
- ﹤sqlMapGenerator targetPackage="???" targetProject="???" /﹥
- ﹤daoGenerator type="IBATIS" targetPackage="???" targetProject="???" /﹥
- ﹤table schema="???" tableName="???"﹥
- ﹤columnOverride column="???" property="???" /﹥
- ﹤/table﹥
- ﹤/abatorContext﹥
- ﹤/abatorConfiguration﹥
你需要做的是替換一些???:
1. 填寫(xiě)driverClass(jdbc驅(qū)動(dòng),例如oracle的就是oracle.jdbc.driver.OracleDriver)
2. 填寫(xiě)connectionURL(連接字符串,例如oracle的就是jdbc:oracle:thin:@192.168.0.246:1521:test)
3. 填寫(xiě)classPathEntry的location(jdbc驅(qū)動(dòng)jar包的位置,例如E:/project/ibatistest/WebContent/WEB-INF/lib/ojdbc14.jar)
4. 填寫(xiě)javaModelGenerator,生成的DTO(java model 類(lèi))
targetPackage:目標(biāo)包的位置,如 com.test.dto
targetProject:目標(biāo)工程名稱(chēng),填寫(xiě)配置文件所在的Eclipse工程名
5. 填寫(xiě)sqlMapGenerator ,生成的xml sqlmap的相關(guān)配置
targetPackage:目標(biāo)位置,如 com.test.sqlmap
targetProject:目標(biāo)工程名稱(chēng),填寫(xiě)配置文件所在的Eclipse工程名
6. 填寫(xiě)daoGenerator ,生成的DAO的相關(guān)配置
type:生成的dao實(shí)現(xiàn)的類(lèi)型,如果你使用spring的話寫(xiě)SPRING,否則寫(xiě)IBATIS
targetPackage:目標(biāo)位置,如 com.test.dao
targetProject:目標(biāo)工程名稱(chēng),填寫(xiě)配置文件所在的Eclipse工程名
7. 配置相關(guān)數(shù)據(jù)庫(kù)的表
schema:數(shù)據(jù)庫(kù)schema,oracle就是填寫(xiě)數(shù)據(jù)庫(kù)的用戶名
tableName:表名
xml 代碼
- ﹤columnOverride column="???" property="???" /﹥
可以先不用配置,刪除就可以了
下面開(kāi)始生成:
在配置文件上點(diǎn)解右鍵,選擇 “Generate iBatis Artifacts”
OK,看看生成了什么吧!
iBATIS for Eclipse設(shè)置問(wèn)題就介紹到這里,是不是有點(diǎn)明白了呢?趕緊動(dòng)手嘗試吧。
【編輯推薦】
- iBATIS是什么?
- iBATIS的優(yōu)、缺點(diǎn)及注意事項(xiàng)淺談
- iBATIS操作Blob與Clob淺析
- iBATIS讀寫(xiě)CLOB數(shù)據(jù)淺析
- iBATIS操作CLOB字段實(shí)戰(zhàn)淺析
當(dāng)前標(biāo)題:iBATISforEclipse設(shè)置淺析
當(dāng)前網(wǎng)址:http://www.dlmjj.cn/article/djppogg.html


咨詢
建站咨詢
