Configuration cfg=new Configuration().configure();app
SessionFactory factory=cfg.buildSessionFactory();单元测试
上面标红的方法在hibernate4中是过期的,而在hibernate5中又恢复了,hibernate5中建立SessionFactory对象可使用上面的方法,在hibernate4中咱们可使用下面的方式建立测试
Session Factoryfactory = cfg.buildSessionFactory(new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build());ui
而在hibernate5中使用hibernate4中建立的方式则是不行的,具体缘由我也不清楚,我也是使用单元测试时报错才发现的spa