使用 JUnit 构建SessionFactory 时脚本出错。我也尝试过使用:
return new Configuration().configure("src/test/resources/META-INF/hibernate.cfg.xml").buildSessionFactory();
我一直在移动它,但每次运行它时。测试方法找不到hibernate.cfg.xml。
特别是我也在使用 Maven2。
错误:
SessionFactory creation failed.org.hibernate.HibernateException: src/test/resources/META-INF/hibernate.cfg.xml not found
我的项目/工作空间名称也是“test”,所以我也尝试了“test/src/test”。没有成功。
最佳答案
删除“src”并再次尝试运行。
return new Configuration().configure("/test/resources/META-INF/hibernate.cfg.xml").buildSessionFactory();
关于java - Hibernate JUnit 找不到 hibernate.cfg.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26495940/