有没有办法在外部使用属性文件禁用ehache?CacheManager.shutdown()似乎不起作用?实际上,我们有两个应用程序与相同的源代码,我需要ehcache在一个,而不是另一个。我不需要缓存的一个地方是webapp!还不知道该怎么做呢?
发布于 2009-11-07 03:50:34
您可以使用一个系统属性来执行此操作:
net.sf.ehcache.disabled=true发布于 2013-03-26 23:13:57
我也遇到了同样的问题,Alex Miller的解决方案帮了我大忙。我确实通过这种技术从属性文件中获得了值:
<!-- Enable/disable ehCache using property in config -->
<bean
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject">
<!-- System.getProperties() -->
<bean
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="java.lang.System" />
<property name="targetMethod" value="getProperties" />
</bean>
</property>
<property name="targetMethod" value="putAll" />
<property name="arguments">
<!-- The new Properties -->
<util:properties>
<prop key="net.sf.ehcache.disabled">${net.sf.ehcache.disabled:false}</prop>
</util:properties>
</property>
</bean>发布于 2017-07-17 18:00:43
检查下面这行
cache.getNativeCache().getCacheManager().getCacheManagerEventListenerRegistry().notifyCacheRemoved("properties");https://stackoverflow.com/questions/1091251
复制相似问题