博客
关于我
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/

    你可能感兴趣的文章
    PHP 5.3.0以上推荐使用mysqlnd驱动
    查看>>
    php aes sha1解密,PHP AES加密/解密
    查看>>
    php CI框架单个file表单多文件上传例子
    查看>>
    reflow和repaint引发的性能问题
    查看>>
    php csv 导出
    查看>>
    php curl 实例+详解
    查看>>
    php curl_init函数用法(http://blog.sina.com.cn/s/blog_640738130100tsig.html)
    查看>>
    php curl_multi批量发送http请求
    查看>>
    php echo 输出 锘?... 乱码问题
    查看>>
    ReferenceQueue的使用
    查看>>
    php flush()刷新不能输出缓冲的原因分析
    查看>>
    Referenced classpath provider does not exist: org.maven.ide.eclipse.launchconfig
    查看>>
    Refactoring-Imporving the Design of Exsiting Code — 代码的坏味道
    查看>>
    PHP imap 远程命令执行漏洞复现(CVE-2018-19518)
    查看>>
    php include和require
    查看>>
    ref 和out 区别
    查看>>
    php JS 导出表格特殊处理
    查看>>
    php json dom解析
    查看>>
    ReentrantReadWriteLock读写锁解析
    查看>>
    php laravel实现依赖注入原理(反射机制)
    查看>>