0
我使用STS并创建了MVC模板项目。我想使用hibernate,但我不知道把hibernate.cfg.xml放在哪里。在默认的项目中,我只是把它放在src /文件夹中。在STS中使用Spring MVC模板配置Hibernate
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
//AnnotationConfiguration
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
我知道我能严格路径添加到hibernate.cfg.xml的那样:
sessionFactory = new Configuration().configure("XXX").buildSessionFactory();
其中XXX是到hibernate.cfg.xml路径。我应该在哪里放hibernate.cfg.xml如果我会 使用“/hibernate.cfg.xml”像路径?谢谢!