Search code examples

IS there a way to configure ehcache 2 for spring boot 3?

I am migrating some legacy app from sb 2 ( spring boot) to sb 3. App is using ehcache with xml configuration to it. In my cacheConfig class I'm using something like this:

import org.springframework.cache.ehcache.EhCacheCacheManager;

class Config {
    CacheManager cacheManager() {
        return new EhCacheCacheManager(ehCacheManager())
    @Bean(destroyMethod = 'shutdown')
    net.sf.ehcache.CacheManager ehCacheManager() {
 URL url = ("/configFile.xml");
    return net.sf.ehcache.CacheManager.newInstance(url);

however import org.springframework.cache.ehcache.EhCacheCacheManager; is no longer present in spring context support 6+ (spring boot 3).

Is there any way to work around it ? How can I configure my ehcache with new spring boot 3?


  • ehcache 2 is no longer supported as cache provider in Spring Boot 3. You would have to use ehcache 3 with JSR-107 annotations: