3

プロパティ ファイルを使用して外部から ehache を無効にする方法はありますか? CacheManager.shutdown() が機能していないようですか? 実際には、同じソース コードを持つ 2 つのアプリがあり、一方には ehcache が必要で、もう一方には必要ありません。私がキャッシュを必要としないのはwebappです! これについてどうすればよいかまだわかりませんか?

4

3 に答える 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 に答える