关于Spring3与Hibernate4整合错误:java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider

主要异常信息:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider


Caused by: java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvide

解决方法:

当Spring与Hibernate4整合的时候,运行会出现上面的错误,主要是因为类库中使用的是Hibernate4而在applicationContext.xml中配置的sessionFactory要将hibernate3更改成hibernate4,如下:

      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

你可能感兴趣的:(Hibernate)