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

    你可能感兴趣的文章
    org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
    查看>>
    org.apache.ibatis.type.TypeException: Could not resolve type alias 'xxxx'异常
    查看>>
    org.apache.poi.hssf.util.Region
    查看>>
    org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
    查看>>
    org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
    查看>>
    org.hibernate.HibernateException: Unable to get the default Bean Validation factory
    查看>>
    org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
    查看>>
    SQL-CLR 类型映射 (LINQ to SQL)
    查看>>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    查看>>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    查看>>
    org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded
    查看>>
    org.tinygroup.serviceprocessor-服务处理器
    查看>>
    org/eclipse/jetty/server/Connector : Unsupported major.minor version 52.0
    查看>>
    org/hibernate/validator/internal/engine
    查看>>
    SQL-36 创建一个actor_name表,将actor表中的所有first_name以及last_name导入改表。
    查看>>
    ORM sqlachemy学习
    查看>>
    Ormlite数据库
    查看>>
    orm总结
    查看>>
    os.environ 没有设置环境变量
    查看>>
    os.path.join、dirname、splitext、split、makedirs、getcwd、listdir、sep等的用法
    查看>>