Grails ehcache插件 - 另一个未命名的CacheManager已存在于同一个VM中

Gil*_*Gil 5 grails ehcache grails-plugin

我使用ehcache为我的二级缓存运行我的Grails应用程序,它可以工作.我安装了ehcache插件+ cache插件,然后没有.我试图从互联网上几乎所有的解决方案,并没有发现任何解决方案,我不断收到Another unnamed CacheManager already exists in the same VM.

其中一个可能的解决方案是设置p:shared=true,EhCacheManagerFactoryBean如果我使用旧的插件"grails的springcache插件",但是使用新的插件,他们使用此管理器的修改版本,并且共享的属性不可用.

我尝试定义一个新ehcache.xml文件但仍然无法为此缓存管理器添加新名称.

我尝试改变cache.provider我内部的类DataSource.groovy来使用另一个EhCacheProvider如a Singleton.

毋庸置疑,我测试了在不同的地方使用DSL的不同名称,但仍然没有运气.

最后,我使用旧的插件进行弹簧缓存,这是不推荐使用的.有人可以帮忙吗?

我正在使用Grails 2.0.3和ehcache-core:2.5.3.

Jos*_*ink 7

hibernate部分中DataSource.groovy,确保您的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
}
Run Code Online (Sandbox Code Playgroud)

我有同样的问题,因为我cache.region.factory_class已经过时了:net.sf.ehcache.hibernate.EhCacheProvider.

请参阅http://grails-plugins.github.io/grails-cache-ehcache/guide/usage.html


Pie*_*IER 5

对于Grails 2.5.x出现此错误的用户,只需将其添加到Config.groovy:

beans {
   cacheManager {
      shared = true
  }
}
Run Code Online (Sandbox Code Playgroud)

这解决了我的问题.

来源:https://github.com/grails/grails-core/releases/tag/v2.5.0