ehcache 冲突_springboot下 shiro使用ehcache和@cacheable冲突的处理

springboot提供缓存注解标签

@Cacheable ,当使用ehcache时,autoconfig机制会根据配置文件自动去初始化bean

而shiroConfig在@Configuration构造时,也会去初始化ehcache ,项目启动会产生如下异常

org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:

1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary

2. Shutdown the earlier cacheManager before creating new one with same name.

按照网上的说,使用低版本的ehcache可解决该问题,没找到完美解决的方法

查看了下源代码

EhCacheCacheConfiguration在

@Bean

@ConditionalOnMissingBean

public net.sf.ehcache.CacheManager ehCacheCacheManager() {

Resource location = this.cacheProperties.resolveConfigLocation(this.cach

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值