Org. springframework. beans. factory. beanCreationException: Error creating bean with name 'sessionfactory 'defined in ServletContext resource [/WEB-INF/config/applicationContext. xml]: Invocation of init method failed; nested exception is org. hibernate. hibernateException: cocould not instantiate cache implementation
......
......
......
Google the exception information first, and most of the solutions are package conflicts. After a series of experiments, we found that it is not the same thing. We continue to look for the following exception information.
Caused by: org. hibernate. HibernateException: cocould not instantiate cache implementation
......
......
......
Caused by: org. hibernate. cache. NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate. cache. use_second_level_cache | hibernate. cache. use_query_cache]
The cache configuration problems were vaguely known, and the applicationContext was found along the instructions. in the xml file, the prompt indicates that the cache is unavailable. After the cache configuration is added, everything works normally.
<Bean id = "sessionFactory"
Class = "org. springframework. orm. hibernate3.annotation. AnnotationSessionFactoryBean">
<Property name = "dataSource" ref = "dataSource"> </property>
<Property name = "hibernateProperties">
<Props>
<Prop key = "hibernate. dialect" >$ {hibernate. dialect} </prop>
<Prop key = "hibernate. show_ SQL" >$ {hibernate. show_ SQL} </prop>
<Prop key = "hibernate. hbm2ddl. auto" >$ {hibernate. hbm2ddl. auto} </prop>
<! -- Add cache configuration -->
<Prop key = "hibernate. cache. provider_class"> org. hibernate. cache. HashtableCacheProvider </prop>
</Props>
</Property>
<! -- Hbm. xml file Loading Method -->
<Property name = "mappingLocations">
<List>
<Value> classpath *:/com/train/entity/admin/hbm/*. hbm. xml </value>
<Value> classpath *:/com/train/entity/common/hbm/*. hbm. xml </value>
</List>
</Property>
</Bean>
Although the reported exceptions are almost the same as those reported by other people on the Internet, there are still some inconsistencies. Only the right medicine can be used to get rid of the disease.