java.lang.NoClassDefFoundError: Could not initialize class xxx.xxx.xxx.HibernateUtil

前端 未结 5 2108
失恋的感觉
失恋的感觉 2020-12-19 12:31

Herewith I added my source code of web.xml




        
5条回答
  •  爱一瞬间的悲伤
    2020-12-19 12:52

    This Kind of an error can be happened when initialization of SessionFactory fails. You have mentioned that you are using hibernate-core-4.3.7. The way you are initializing the SessionFactory is not the correct for this version. Use Hibernate version 3.x or change the way you are initializing the SessionFactory. Below is the correct way to build the session factory in Hibernate 4.x +.

    Configuration configuration = new Configuration().configure();
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().
    applySettings(configuration.getProperties());
    SessionFactory factory = configuration.buildSessionFactory(builder.build());
    

提交回复
热议问题