EHCache禁用

时间:2009-07-07 09:21:58

标签: ehcache

有没有办法在外部使用属性文件禁用ehache? CacheManager.shutdown()似乎不起作用?实际上我们有2个应用程序具有相同的源代码我需要ehcache在一个而不是另一个。我不需要缓存的一个是webapp!无法想出如何解决这个问题?

3 个答案:

答案 0 :(得分:6)

您可以使用系统属性:

net.sf.ehcache.disabled=true

答案 1 :(得分: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>

答案 2 :(得分:0)

检查以下行

some_field
相关问题