Hibernate4 废弃了之前创建SessionFactory的方法,即由原来的
Configuration cfg = new Configuration();
SessionFactory sf = cfg.configure().buildSessionFactory();
官网提供为
Configuration cfg = new Configuration();
SessionFactory sf = cfg.configure().buildSessionFactory(
new StandardServiceRegistryBuilder().build() );
亲自测了下老是报错 Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
于是换为了
Configuration configuration = new Configuration().configure();
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
SessionFactory sf = configuration.buildSessionFactory(serviceRegistry);
问题得到解决!!
九层之台,始于累土