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

huangapple go评论78阅读模式
英文:

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;

@Configuration
@EnableCaching
class Config {
    @Bean
    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?

英文:

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;


@Configuration
@EnableCaching
class Config {
    @Bean
    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?

答案1

得分: 1

ehcache 2 在 Spring Boot 3 中不再受支持作为缓存提供程序。您需要使用 ehcache 3 与 JSR-107 注解:https://docs.spring.io/spring-boot/docs/3.0.8/reference/html/io.html#io

英文:

ehcache 2 is no longer supported as cache provider in Spring Boot 3. You would have to use ehcache 3 with JSR-107 annotations: https://docs.spring.io/spring-boot/docs/3.0.8/reference/html/io.html#io

huangapple
  • 本文由 发表于 2023年7月4日 20:38:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76612735.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定