Hibernate将classname.hbm.xml放在哪里 [英] Hibernate where to put classname.hbm.xml

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

问题描述

我的朋友Google告诉我,我应该将classname.hbm.xml放在classname.java所在的位置。
但它不起作用,说

My friend Google told me I should put the classname.hbm.xml to where classname.java stays at. But it doesn't work, saying


资源:找不到AccountsRequest.hbm.xml

AccountsRequest是java类名。我用javac编译。不确定是不是这个原因。 AccountsRequest.java位于/ WEB-INF / src /.

AccountsRequest is the java class name. I use javac to compile. Not sure if it is the reason. AccountsRequest.java is at /WEB-INF/src/.

已编辑:在hibernate.cfg.xml中我有

EDITED: in hibernate.cfg.xml i have


resource =AccountsRequest.hbm.xml/>

resource="AccountsRequest.hbm.xml"/>

hibernate.cfg.xml位于/ WEB-INF /.

hibernate.cfg.xml is at /WEB-INF/.

谢谢!

推荐答案

您需要将它放在运行时类路径中。 Web应用程序的默认运行时类路径涵盖 / WEB-INF / classes 。所以它应该在那里结束。

You need to put it in the runtime classpath. The /WEB-INF/classes is covered by the webapp's default runtime classpath. So it should end up there.

但是,如果你使用的是IDE,你也可以将它们放在项目的 src 文件夹中(不, / WEB-INF / src !),一个不错的IDE会自动将它放入 / WEB在构建期间-INF / classes

However, if you're using an IDE, you can also drop them in src folder of the project (no, not /WEB-INF/src!), a bit decent IDE will then automagically put it in /WEB-INF/classes during build.

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

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