Search code examples
spring-boothibernatespring-data-jpaehcache-3

How to implement second-level caching in Spring Boot 3 using Ehcache 3?


I've been trying to find a way to implement second-level caching using Spring Boot 3 + Ehcache 3 + Hibernate 6 but it's been an unsuccessful ride so far.

I tried looking it up on the internet but no tutorial exists. Maybe I'm the first one?

Edit: Basically the issue is with dependencies. Spring Boot 3 needs Jakarta but Ehcache is using Javax. There are also lots of unavailable dependencies from EhCache 3. Forcing everything together just does not work.

Can anyone help?


Solution

  • Starting with Ehcache version 3.10 there's a Jakarta EE version which you can declare like this in Spring Boot 3.x projects:

    <dependency>
      <groupId>org.ehcache</groupId>
      <artifactId>ehcache</artifactId>
      <classifier>jakarta</classifier>
    </dependency>
    

    See https://github.com/ehcache/ehcache3/releases/tag/v3.10.0.