将Hibernate配置放在不同的位置 [英] Place Hibernate configuration in a different location
问题描述
Hibernate 配置文件(.hbm.xml)的理想位置是
... / tomcat / webapps / projectName / WEB-INF / classes / hbm
但我想将这些配置设置放在不同的位置,例如
/ usr / local / properties / hibernate
?
如果我将该配置文件放在该位置,如果我开始 Tomcat 然后它给我一个错误,加载配置说
hibernate.cfg.xml找不到
配置 .cfg.xml
文件使用 Configuration.configure()
而不是
另请参阅: b
The ideal place for Hibernate configuration files (.hbm.xml) is
.../tomcat/webapps/projectName/WEB-INF/classes/hbm
But I want to place those configurations settings in a different location, say
/usr/local/properties/hibernate
How can I do that?
If I place that configuration files in that location and if I start Tomcat then it gives me an error on loading that configurations saying
hibernate.cfg.xml not found
To configure location of .cfg.xml
file use Configuration.configure(File)
instead of Configuration.configure()
when creating SessionFactory
.
To configure location of .hbm.xml
files use Configuration.addDirectory()
.
See also:
这篇关于将Hibernate配置放在不同的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!