遇到错误org.hibernate.jpa.HibernateEntityManagerFactory无法解析

时间:2016-11-06 19:04:05

标签: java hibernate

当我将Hibernate版本从5.0降级到4.3.11.Final时,遇到了以下错误。我试过谷歌但却找不到任何东西。

无法解析org.hibernate.jpa.HibernateEntityManagerFactory类型。它是从必需的.class中间接引用的  文件

   private synchronized SessionFactory initSessionFactory() {

      if (sessionFactory == null) {
         Configuration configuration = new Configuration();
         configuration.configure();

         serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();

         sessionFactory = configuration.buildSessionFactory(serviceRegistry);
      }

      return sessionFactory;
   }

   public Session getSession() {

      if (session == null) {

         session = initSessionFactory().openSession();

      } else {

         session = initSessionFactory().getCurrentSession();

      }

      return session;
   }

更新

通过运行以下命令修复了该问题

mvn eclipse:clean to clear .project .classpath .settings in the folder
mvn clean install to clear target and build the project will also download jars if you deleted .m2 (like in my case)
mvn eclipse:eclipse so i can update/import project in eclipse

0 个答案:

没有答案