求告知,hibernate错误
org.hibernate.service.ServiceRegistryBuilder cannot be cast to org.hibernate.service.ServiceRegistry 这个是为什么啊??
org.hibernate.service.ServiceRegistryBuilder cannot be cast to org.hibernate.service.ServiceRegistry 这个是为什么啊??
2017-07-18
5版本导入更换为:
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
在4版本中
Configuration conf = new Configuration().configure();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(conf.getProperties()).buildServiceRegistry();
SessionFactory sf = conf.buildSessionFactory(serviceRegistry);
在5版本的Hibernate中,buildServiceReguistry()方法被替换了,用如下方法:
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(conf.getProperties()).build();
举报