hibernate,无法找到ServiceRegistry类

时间:2014-01-17 10:07:23

标签: eclipse hibernate

我正在尝试运行此功能 http://www.tutorialspoint.com/hibernate/hibernate_examples.htm 它爆炸了

factory = new Configuration().configure().buildSessionFactory();

所以我按照第4版中的说明进行了操作

   private static SessionFactory configureSessionFactory() throws HibernateException {
       Configuration configuration = new Configuration();
       configuration.configure();
       serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();        
       sessionFactory = configuration.buildSessionFactory(serviceRegistry);
       return sessionFactory;
   }

但是它无法找到ServiceRegistry,这会失败

import org.hibernate.ServiceRegistry;

实际上我从我下载的/hibernate-search-4.4.2.Final导入的jar文件中遗漏了它,即它不在hibernate-core-4.2.8.Final.jar

1 个答案:

答案 0 :(得分:3)

使用hibernate-core-4.0.1.Final.jar