博客
关于我
eclipse+hibernate配置文件自动提示
阅读量:114 次
发布时间:2019-02-26

本文共 945 字,大约阅读时间需要 3 分钟。

在Eclipse中配置Hibernate时,默认情况下不会提供对hibernate配置文件的自动提示。这是因为Eclipse不直接支持对hibernate配置文件的智能提示。为了实现这一功能,我们需要手动配置Eclipse,添加hibernate的DTD文件。

首先,我们需要解压hibernate的核心jar包。以hibernate4.3.10.Final为例,解压后会找到org/hibernate目录下的hibernate-mapping-3.0.dtd和hibernate-configuration-3.0.dtd文件。

接下来,按照以下步骤配置Eclipse:

  • 打开Eclipse的偏好设置(Window -> Preferences -> XML -> XML Catalog)。
  • 点击右侧的“Add”按钮,进入添加Catalog Entry的界面。
  • 在弹出的窗口中,选择文件位置,输入hibernate-mapping-3.0.dtd的路径,设置key type为URI,key值为“http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd”。
  • 点击“OK”完成添加。
  • 同样地,处理hibernate-configuration-3.0.dtd文件,重复上述步骤,添加相应的DTD路径。

    接下来,创建hibernate映射文件:

  • 选择“File -> New -> Create XML File from DTD File”,然后点击“Next”。
  • 在出现的选择Catalog Entry的窗口中,选择我们之前添加的hibernate catalog entry。
  • 输入Public ID: "-//Hibernate/Hibernate Mapping DTD 3.0//EN",点击“Finish”。
  • 这样就会生成一个user.hbm.xml文件,内容如下:
  • 生成的文件无需修改即可使用。对于hibernate.cfg.xml,使用方法相同,需要使用hibernate-configuration-3.0.dtd文件。

    通过以上步骤,我们可以实现Eclipse对hibernate配置文件的智能提示功能。

    转载地址:http://bkey.baihongyu.com/

    你可能感兴趣的文章
    Qt笔记——标准文件对话框QFileDialog
    查看>>
    poj 3083 Children of the Candy Corn
    查看>>
    POJ 3083 Children of the Candy Corn 解题报告
    查看>>
    POJ 3253 Fence Repair C++ STL multiset 可解 (同51nod 1117 聪明的木匠)
    查看>>
    Qt笔记——控件总结
    查看>>
    poj 3262 Protecting the Flowers 贪心
    查看>>
    poj 3264(简单线段树)
    查看>>
    Qt笔记——布局管理三件套分割窗口、停靠窗口和堆栈窗口
    查看>>
    poj 3277 线段树
    查看>>
    POJ 3349 Snowflake Snow Snowflakes
    查看>>
    POJ 3411 DFS
    查看>>
    poj 3422 Kaka's Matrix Travels (费用流 + 拆点)
    查看>>
    Qt笔记——官方文档全局定义(二)Functions函数
    查看>>
    POJ 3468 A Simple Problem with Integers
    查看>>
    poj 3468 A Simple Problem with Integers 降维线段树
    查看>>
    poj 3468 A Simple Problem with Integers(线段树 插线问线)
    查看>>
    poj 3485 区间选点
    查看>>
    poj 3518 Prime Gap
    查看>>
    poj 3539 Elevator——同余类bfs
    查看>>
    Qt笔记——官方文档全局定义(三)Macros宏
    查看>>