Hibernate的hibernate.cfg.xml [英] hibernate.cfg.xml of Hibernate

查看:96
本文介绍了Hibernate的hibernate.cfg.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Java项目中, hibernate.cfg.xml 位于源文件夹-\ src中.因此,确切地说,它是源文件夹中的文件,位于 源代码.

In my Java Project, hibernate.cfg.xml is sitting in the source folder-- \src. So, to be precise, it is a file in the source folder, sitting right next to the source codes.

但是,Eclipse无法看到它.请参阅休眠-对象创建错误以了解 问题的背景.

However, Eclipse can't see it. Please see for Hibernate -- object creation error for the background of this Q.

我的jar文件放在/应该放在正确的位置. hibernate.cfg.xml 的标头是安装包中的配置文件之一的精确副本.

My jar files are/should be in right places. And the header of hibernate.cfg.xml is the exact copy of one of the config files out of the installation package.

在项目中有无 hibernate.cfg.xml 的情况下,我都看到相同的错误日志-这就是我知道未对其进行处理的方式.

I am seeing the same error log with and without hibernate.cfg.xml in the project-- that's how I know it's not being processed on.

hibernate.cfg.xml 应该在哪里?

推荐答案

完全相同的代码-调用类和DTO都在我从头开始设置的另一个项目中工作. 设置和库的位置和代码是相同的,其他环境设置(都是默认的Eclipse)也是如此.

Exact same code-- both the calling class and DTOs worked in another project i set up from scratch. The setup & placement of libraries and the codes are the same, so are the other environment setting (all default Eclipse).

唯一的区别是后面的数据库和相关的配置文件设置.我在前一个版本中使用了postgreSQL,并根据它在config中设置了相关标签.第二个是DB,起作用的是MySQL.在这些相关标签之外,两个项目中的 hibernate.cfg.xml 文件是相同的-一组完全相同的标签,以及非postgreSQL/non-MySQL属性的值.

The only difference is the DBs behind and the related config file settings. I used postgreSQL in the former one and set the related tags in config according to that. The DB in the second, the one that worked is MySQL. Outside of these related tags, the hibernate.cfg.xml file is the same in the two projects-- the exact same set of tags, and values of non-postgreSQL/non-MySQL properties.

据我所知,配置是一门阅读&处理配置文件.并且由于其他所有内容都完全相同,因此在前一个项目中的postgreSQL设置中一定是一个错误.

From what I know, Configure is a class reading & processing on the config file. and since everything else is the exact same, must be a mistake in postgreSQL setting in the former project.

这篇关于Hibernate的hibernate.cfg.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆