我在二级缓存中使用ehcache运行我的Grails应用程序,它可以工作。我安装了ehcache plugin + cache插件,但它没有,我尝试了几乎所有来自互联网的解决方案,都没有找到解决方案,我一直得到Another unnamed CacheManager already exists in the same VM。
一种可能的解决方案是在EhCacheManagerFactoryBean中设置p:shared=true,如果我使用一个旧的插件“来自grails的springcache插件”,但对于新的插件,他们使用的是这个管理器的修改版本,并且共享的属性不可用,这是可行的。
我尝试定义一个新的ehcache.xml文件,但是仍然不能为这个缓存管理器添加一个新的名称。
我尝试更改DataSource.groovy中的cache.provider类,以使用另一个EhCacheProvider,比如Singleton。
不用说,我使用DSL在不同的地方测试了一个不同的名称,但仍然没有成功。
最后,我使用了spring cache的旧插件,这个插件已经被弃用了。有人能帮上忙吗?
我使用的是Grails 2.0.3和ehcache-core:2.5.3。
发布于 2014-07-17 02:20:58
在DataSource.groovy的hibernate部分,确保您的cache.provider.class是最新的:
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'grails.plugin.cache.ehcache.hibernate.BeanEhcacheRegionFactory' // For Hibernate before 4.0
cache.region.factory_class = 'grails.plugin.cache.ehcache.hibernate.BeanEhcacheRegionFactory4' // For Hibernate before 4.0 and higher
}我也有同样的问题,因为我的cache.region.factory_class已经过时了:net.sf.ehcache.hibernate.EhCacheProvider。
请参阅http://grails-plugins.github.io/grails-cache-ehcache/guide/usage.html
发布于 2015-03-28 20:37:36
对于那些在Grails 2.5.x中遇到此错误的人,只需将以下内容添加到Config.groovy:
beans {
cacheManager {
shared = true
}
}这为我解决了这个问题。
来源:https://github.com/grails/grails-core/releases/tag/v2.5.0
发布于 2013-04-09 15:40:27
尝试使用缓存和缓存-ehcache插件,它对我来说是有效的,但有一些限制。但是对于2ndlevel Cache,它可以正常工作
https://stackoverflow.com/questions/15657360
复制相似问题