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」像路徑?謝謝!