1. 程式人生 > >解決hibernate中配置檔案沒有提示的問題

解決hibernate中配置檔案沒有提示的問題

 

解決方法:

第一種:

有網的時候,只要在配置檔案中引入約束,就可以了。
該約束如下:<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

注意:這是configuration配置的約束,如果是mapping,則引入mapping的約束,如下:


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


第二種:

不能上網 的時候,
則需要匯入該約束的檔案

這裡只以myeclipse為例

點選windows,再點選preferences,
在出現的視窗中搜索xml.catalog,在右側視窗中點選add,在location中選擇約束檔案的位置,
在key type中選擇URL,

在key中填寫約束檔案的網路地址,configuration是:http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd。

如果是mapping的,則是:http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd


最後點選確定。


ps:約束檔案的位置在:所下載的hibernate-relaese-5.0.12.Final資料夾中,


project--->hibernate-core--->src--->main--->resources--->org--->hibernate的資料夾下