How to configure second level cache in Hibernate 4.1.5 SP1?

前端 未结 3 888
面向向阳花
面向向阳花 2021-01-02 21:28

I have read other threads on here about this subject but none of the solutions work for me.

I tried putting this in my hibernate.cfg.xml:



        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-02 22:08

    Well, I found the answer (from a Youtube user):

    1. Use hibernate-release-4.1.0.Final or later versions.
    2. Add jars from lib\optional\ehcache directory
    3. Update hibernate.cfg.xml:

      org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
      
    4. Add slf4j-api-1.6.1.jar (I found it in ehcache-2.5.1-distribution.tar­.gz downloaded from ehcache.org in addition) because of ClassNotFoundException.

    5. Add this to your hibernate.cfg.xml:

      
      true
      

    The key point here was adding the ehcache jar from the optional\ directory in Hibernate4.

提交回复
热议问题