1. 程式人生 > >eclipse中hibernate配置*.hbm.xml檔案和hibernate.cfg.xml檔案使其能自動提示

eclipse中hibernate配置*.hbm.xml檔案和hibernate.cfg.xml檔案使其能自動提示

剛開始接觸hibernate,不知道*.hbm.xml檔案和hibernate.cfg.xml檔案中都有什麼屬性,於是研究了一下怎麼能在eclipse中自動提示。

我用的eclipse版本是Luna Service Release 2 (4.4.2)。hibernate版本是hibernate-distribution-3.6.10.Final。hibernate檔案下載地址:http://sourceforge.net/projects/hibernate/files/

eclipse配置步驟(以*.hbm.xml檔案的配置為例,hibernate.cfg.xml檔案的配置相似):

1、  將專案中使用的hibernate3.jar檔案解壓,找到org資料夾下的hibernate-mapping-3.0.dtd檔案。

2、eclipse -> Window -> Preferences -> Weband XML(或XML) -> XML Catalog點選add,在彈出的Add XML Catalog 對話方塊中,location裡選擇上面找到的hibernate-mapping-3.0.dtd檔案位置,Key Type中選擇URI,輸入*.hbm.xml檔案中顯示的http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd(不同檔案會有不同的格式。)

URI的查詢方式為:隨便開啟專案中的一個*.hbm.xml檔案,找到相應的地址,如下:

<!DOCTYPE hibernate-configuration PUBLIC

         "-//Hibernate/HibernateConfiguration DTD 3.0//EN"

         "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

3、最後重啟eclipse就可以