2010-04-29 56 views
0

我可以带上泽西+灰熊服务器了。但是在SessionFactory sessionFactory = new Configuration().configure()。buildSessionFactory;“ 错误说“重度:服务异常:org.hibernate.HibernateException:/hibernate.cfg.xml没有找到泽西宁静+灰熊服务器+休眠

..任何人都知道如何让Hibernate可以直接访问hibernate.cfg.xml的位置

回答

0

把它。如果你已经指定了“/hibernate.cfg.cml”,请尝试删除斜杠,使其显示“hibernate.cfg.xml”

如果该项目位于“src/main/resources”不起作用(没有目录,类路径错误等),您可以对其进行硬编码以使其工作。

File f = new File("/wherever/the/file/is/hibernate.cfg.xml"); 
sessions = new Configuration().configure(f).buildSessionFactory(); 

然后稍后圈回来偿还你的技术债务。