有没有办法使用属性文件在外部禁用 ehache?CacheManager.shutdown() 似乎不起作用?实际上,我们有 2 个具有相同源代码的应用程序,我需要 ehcache 在一个而不是另一个。我不需要缓存的一个是 webapp!无法弄清楚如何解决这个问题?
问问题
5491 次
3 回答
7
您可以为此使用一个系统属性:
net.sf.ehcache.disabled=true
于 2009-11-06T19:50:33.577 回答
1
我遇到了同样的问题,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>
于 2013-03-26T15:13:56.607 回答
0
检查以下行
cache.getNativeCache().getCacheManager().getCacheManagerEventListenerRegistry().notifyCacheRemoved("properties");
于 2017-07-17T10:00:42.990 回答