Eclipse中hibernate.cfg.xml配置文件加上自动提示功能

在敲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】.

效果图:

猜你喜欢

转载自blog.csdn.net/alexzt/article/details/81700879