Another unnamed CacheManager already exists in the same VM.解决方法
2017-05-10 18:12
1251 查看
Caused by: 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.
出现这个错误,看源码
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/20/1ae990b9c5465d0ca17268ef4a836e00)
就是configuration.getName()的名字不为null或者为null就使用默认的
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/20/210ad732dd2e0f1bd3cf48402906d5cf)
这里这个name的值是不是存在,不存在就给个默认的,存在就取这个name的值。
之后CACHE_MANAGERS_MAP这个map通过这个name的key值取获取值,如果获取不到就是null,那就添加,如果获取到了,就报上面那个错,说已经初始化过了。也就是跟你有没有写name其实没有关系。因为这个put添加操作只会在这里执行,所以报这个错就表明你的代码走了2次这个地方,已经添加过一次了,一般是初始化的时候初始化了2次
<property name="net.sf.ehcache.configurationResourceName" value="ehcache.xml" />这个类了
找到问题所在就找出我们在哪里初始化了2次这个地方
第一个地方,在配置文件里面初始化了c3p0,里面就有这个缓存类的初始化。
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/20/ff5275596b70e7a5001179519f80eb59)
第二个地方,在basedao里面又初始化了一次c3p0,所以报错
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/20/2c0435905afdac7e34ea10c9ae90436c)
所以注释掉它就可以了。
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.
出现这个错误,看源码
就是configuration.getName()的名字不为null或者为null就使用默认的
这里这个name的值是不是存在,不存在就给个默认的,存在就取这个name的值。
之后CACHE_MANAGERS_MAP这个map通过这个name的key值取获取值,如果获取不到就是null,那就添加,如果获取到了,就报上面那个错,说已经初始化过了。也就是跟你有没有写name其实没有关系。因为这个put添加操作只会在这里执行,所以报这个错就表明你的代码走了2次这个地方,已经添加过一次了,一般是初始化的时候初始化了2次
<property name="net.sf.ehcache.configurationResourceName" value="ehcache.xml" />这个类了
找到问题所在就找出我们在哪里初始化了2次这个地方
第一个地方,在配置文件里面初始化了c3p0,里面就有这个缓存类的初始化。
第二个地方,在basedao里面又初始化了一次c3p0,所以报错
所以注释掉它就可以了。
相关文章推荐
- Another unnamed CacheManager already exists in the same VM.解决方法
- Another unnamed CacheManager already exists in the same VM (ehCache 2.5) 解决办法
- Another unnamed CacheManager already exists in the same VM
- 在整合springmvc+mybatis+ecache时候报错如下: Another unnamed CacheManager already exists in the same VM.
- Hibernate 异常CacheException: Another unnamed CacheManager already exists in the same VM
- hibernate3与ehcache-2.8.3配合使用,在多个SessionFactory实例的情况下出现“Another unnamed CacheManager already exists in the same VM”问题
- Another unnamed CacheManager already exists in the same VM
- net.sf.ehcache.CacheException: Another unnamedCacheManager already exists in the same VM
- Another unnamed CacheManager already exists in the same VM
- net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM.
- Ehcache配置时出错- Another unnamed CacheManager already exists in the same VM. Please provide unique name
- SpringBoot--P-1:缓存 Another unnamed CacheManager already exists in the same VM.
- Ehcache依赖版本问题:Another CacheManager with same name 'es' already exists in the same VM.
- Excel导入遇到的问题An object with the same key already exists in the ObjectStateManager……
- This platform could not be created because a solution platform of the same name already exists解决方法
- 关于a different object with the same identifier value was already associated with the session错误的一种解决方法
- the file is already open in an editor 解决方法
- The servlet name already exists.解决方法
- Another MySQL daemon already running with the same unix socket的解决
- Socket file /var/lib/mysql/mysql.sock exists. Is another MySQL daemon already running with the same