Is there a way to disable ehache externally using a property file? CacheManager.shutdown() doesnt seem to work? Actually we have 2 app with the same source code i require ehcache in one and not the other. one where i dont need cache is a webapp! Unable to figure to out yet how to go about this?
Asked
Active
Viewed 5,925 times
3 Answers
8
There is a system property you can use for this:
net.sf.ehcache.disabled=true

Alex Miller
- 69,183
- 25
- 122
- 167
-
1but it means that I need to add it to the arguments of the java command (as -Dnet.sf.ehcache.disabled=true). But I want it to have in my app.properties, so do not needed to change it externally in the tomcat startup options, etc.. how can I do that? – javagirl Nov 21 '11 at 16:46
-
not sure - you might want to ask here: http://forums.terracotta.org/forums/forums/show/16.page – Alex Miller Nov 27 '11 at 03:01
-
to clarify: this does not seem to work in spring's application.properties files – serv-inc Aug 02 '23 at 06:36
1
I had the same problem and Alex Miller's solution helped me along. I do get the value from a properties file via this technique:
<!-- 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>

Hendrik
- 1,355
- 3
- 11
- 30