乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Abator —— IBatis 代碼生成工具

       WindySky 2009-03-19

      對(duì)于IBatis應(yīng)用最煩人的重復(fù)工作就是不停的寫DAO,DTO,和xml文件里面的sqlmap,其實(shí)很多時(shí)候這些工作是重復(fù)而且無(wú)聊的。好在我們還有abatorhttp://ibatis./abator.html ),一個(gè)IBatis自動(dòng)生成工具,他可以幫助你生成大量的DAO,DTO和sqlmap。
      如果你使用eclipse作為IDE那么事情就很簡(jiǎn)單了(相信沒有幾個(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輸入框中填寫 http://ibatis./tools/abator ,Name輸入框就隨便寫些什么了。
          點(diǎn)擊Finish,安裝插件,然后重新啟動(dòng)eclipse
      下面測(cè)試一下功能
      1. 新建一個(gè)java工程
      2. 在eclipse菜單欄中興建一個(gè) abator 配置文件
          File -->  Abator  for  iBatis Configration File
      好的,我們完成了創(chuàng)建配置文件,下面打abator配置文件,看看里面怎么去配置
      打開后內(nèi)容基本上是這樣

      xml 代碼

      1. <?xml version="1.0" encoding="UTF-8"?>
      2. <!DOCTYPE abatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN"   
      3.   "http://ibatis./dtd/abator-config_1_0.dtd">
      4.  
      5. <abatorConfiguration>
      6. <abatorContext> <!-- TODO: Add Database Connection Information -->
      7. <jdbcConnection driverClass="???"
      8. connectionURL="???"
      9. userId="???"
      10. password="???">
      11. <classPathEntry location="???" />
      12. </jdbcConnection>
      13.  
      14. <javaModelGenerator targetPackage="???" targetProject="???" />
      15. <sqlMapGenerator targetPackage="???" targetProject="???" />
      16. <daoGenerator type="IBATIS" targetPackage="???" targetProject="???" />
      17.  
      18. <table schema="???" tableName="???">
      19. <columnOverride column="???" property="???" />
      20. </table>
      21.  
      22. </abatorContext>
      23. </abatorConfiguration>

      你需要做的是替換一些???:
      1. 填寫driverClass(jdbc驅(qū)動(dòng),例如oracle的就是oracle.jdbc.driver.OracleDriver)
      2. 填寫connectionURL(連接字符串,例如oracle的就是jdbc:oracle:thin:@192.168.0.246:1521:test)
      3. 填寫classPathEntry的location(jdbc驅(qū)動(dòng)jar包的位置,例如E:/project/ibatistest/WebContent/WEB-INF/lib/ojdbc14.jar)
      4. 填寫javaModelGenerator,生成的DTO(java model 類)
          targetPackage:目標(biāo)包的位置,如 com.test.dto
          targetProject:目標(biāo)工程名稱,填寫配置文件所在的eclipse工程名
      5. 填寫sqlMapGenerator ,生成的xml sqlmap的相關(guān)配置
          targetPackage:目標(biāo)位置,如 com.test.sqlmap
          targetProject:目標(biāo)工程名稱,填寫配置文件所在的eclipse工程名
      6. 填寫daoGenerator ,生成的DAO的相關(guān)配置
          type:生成的dao實(shí)現(xiàn)的類型,如果你使用spring的話寫SPRING,否則寫IBATIS
          targetPackage:目標(biāo)位置,如 com.test.dao
          targetProject:目標(biāo)工程名稱,填寫配置文件所在的eclipse工程名
      7. 配置相關(guān)數(shù)據(jù)庫(kù)的表
          schema:數(shù)據(jù)庫(kù)schema,oracle就是填寫數(shù)據(jù)庫(kù)的用戶名
          tableName:表名

      xml 代碼

      1. <columnOverride column="???" property="???" />

           可以先不用配置,刪除就可以了
      下面開始生成:
      在配置文件上點(diǎn)解右鍵,選擇 “Generate iBatis Artifacts”
      OK,看看生成了什么吧!

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多