将 Hibernate 配置放在不同的位置

发布于 2025-01-01 05:49:24 字数 481 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音栖息无 2025-01-08 05:49:24

要配置 .cfg.xml 文件的位置,请在创建 SessionFactory 时使用 Configuration.configure(File) 而不是 Configuration.configure()

要配置 .hbm.xml 文件的位置,请使用 Configuration.addDirectory()

另请参阅:

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:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文