将 Hibernate 配置放在不同的位置
Hibernate 配置文件 (.hbm.xml) 的理想位置是
.../tomcat/webapps/projectName/WEB-INF/classes/hbm
但我想要要将这些配置设置放在不同的位置,请说
/usr/local/properties/hibernate
我该怎么做?
如果我将该配置文件放在该位置并且启动 Tomcat 那么它会给我一个错误加载该配置说
未找到 hibernate.cfg.xml
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要配置
.cfg.xml
文件的位置,请在创建SessionFactory 时使用
。Configuration.configure(File)
而不是Configuration.configure()
要配置
.hbm.xml
文件的位置,请使用Configuration.addDirectory()
。另请参阅:
To configure location of
.cfg.xml
file useConfiguration.configure(File)
instead ofConfiguration.configure()
when creatingSessionFactory
.To configure location of
.hbm.xml
files useConfiguration.addDirectory()
.See also:
Configuration
javadoc