3
firends IM使用NetBeans IDE和在默认的src/java文件夹 其放置的hibernate.cfg.xml但每当我运行该应用程序其下面显示错误:初始会话工厂创建失败休眠错误
Initial SessionFactory creation failed.org.hibernate.HibernateException: /hibernate.cfg.xml not found
类:
public class myutil {
private static final SessionFactory sessionFactory = buildsf();
public static SessionFactory buildsf() {
try {
// Create the SessionFactory from standard (hibernate.cfg.xml)
return new Configuration().configure("config/hibernate.cfg.xml").buildSessionFactory();
} catch (Throwable ex) { // Log the exception.
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
}
config目录我需要创建吗? –
好吧,保持单独的包/目录配置。你也可以在那里给你的路。 –
非常感谢你的兄弟 –