简体   繁体   中英

Cannot find class [org.hibernate.cache.EhCacheProvider] using Second-level cache of Hibernate

I'm following a tutorial using second-level cache of Hibernate. The hibernate version is hibernate-core-4.3.10.Final.jar .But when I configure it in hibernate.cfg.xml with properties hibernate.cache.provider_class . The value should be org.hibernate.cache.EhCacheProvider according to the tutorial. But in my case, I can't find this class. I checked the jar file and didn't find this class in it.

Does anyone know where it's placed? Is it changed because of the version?

When I searched this issue online, I found that there's other ways configuring the second-level cache of Hibernate. It will be grateful if you can explain this as well.

Thanks in advance.

In the ehcache site you will find documentation about hibernate integration.

For Hibernate 4 use org.hibernate.cache.ehcache.EhCacheRegionFactory

Also check that you have the correct hibernate-ehcache library. If you are using maven, the dependency for H4 is:

<dependency>
   <groupId>org.hibernate</groupId>  
   <artifactId>hibernate-ehcache</artifactId>
   <version>4.0.0</version>
</dependency>

Edit: here is a guy that get all the needed libaries directly from ehcache distribution zip , maybe is your case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM