Eclipse中hibernate.cfg.xml設定檔加上自動提示功能

來源:互聯網
上載者:User


在敲Hibernate例子的時候,我添加一個設定檔的時候,hibernate.cfg.xml沒有提示功能。這是因為,我沒有設定DTD檔案有問題,不是同一個版本的。重新匯入了DTD檔案就好了。同樣的情況下,可以通過匯入DTD的檔案實現自動提示功能。

比如:

舉個栗子:hibernate.cfg.xml的設定檔顯示自動提示

1,倒開Eclipse,找到【window】->【preference】->【xml】->【xml catalog】



2、選中 user specified entried,選擇左邊【Add..】按鈕,填寫三項操作,點擊確定。
(1)location:選本地hibernate-mapping-3.0.dtd所在路徑。這個檔案在hibernate檔案中,需要我們下載加壓好的。
例如,我使用的是hibernate-release-4.1.1.Final版本,路徑是:D:\Hibernate\hibernate-release-4.1.1.Final\project\hibernate-core\src\main\resources\org\hibernate。

(2)Key type:URI。在type一定要選URI。
(3)Key:http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd。可以在dtd檔案裡找到,key就將hibernate設定檔中的dtd檔案粘上去就可以了。或者直接貼這個也行。






3、關閉設定檔,重新開啟即可。如果不行檢查一下XML檔案的開啟檔案。最好選擇【XML Editor】.


效果圖:





聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.