在现有的java项目中加载hibernate.cfg.xml [英] load hibernate.cfg.xml in existing java project
问题描述
我尝试将hibernate.cfg.xml加载到一个现有项目。对于该项目,存在一个build.xml,它正确地构建和部署项目。详细地,它构建一个包含我的CustomController.class和其他自定义* .class文件的jar文件,并将该jar推送到服务器上的正确目录中。如果我也像我的CustomController.class文件那样放置hibernate.cfg.xml文件,我无法通过
I try to load hibernate.cfg.xml in a submodule (ssf/samples/customcontroller) of an existing project. For this project there exists a build.xml which builds and deploys the project properly. In detail it builds a jar file which contains my CustomController.class and other custom *.class files and push that jar into the right directory on the server. If I also put the hibernate.cfg.xml file like my CustomController.class file I'm not able to load this file via
Configuration cfg = new Configuration().configure("hibernate.cfg.xml");
推荐答案
我假设您的类路径设置为src目录。然后你应该使用
I assume that your classpath is set to the src directory. Then you should use
Configuration cfg = new Configuration().configure("resources/hibernate.cfg.xml");
这篇关于在现有的java项目中加载hibernate.cfg.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!