title: Spring MVC - configuring Ehcache - Not caching
body: <p>I am trying to integrate Ehcache with my Java Spring MVC Web Applications. I have followed the instructions from the following article:
  <a href="https://dzone.com/articles/implementing-ehcache-using" rel="nofollow noreferrer">https://dzone.com/articles/implementing-ehcache-using</a>.
  I have added the following dependency to my <code>pom.xml</code> file:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;net.sf.ehcache&lt;/groupId&gt;
      &lt;artifactId&gt;ehcache&lt;/artifactId&gt;
      &lt;version&gt;2.9.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>My <code>ehcache.xml</code> is as follows:</p>
  
  <pre><code>&lt;ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="ehcache.xsd"
      updateCheck="true"
      monitoring="autodetect"
      dynamicConfig="true"&gt;
  
      &lt;diskStore path="java.io.tmpdir" /&gt;
  
      &lt;cache name="swcmRestData"
          maxEntriesLocalHeap="10000"
          maxEntriesLocalDisk="1000"
          eternal="false"
          diskSpoolBufferSizeMB="20"
          timeToIdleSeconds="300" timeToLiveSeconds="600"
          memoryStoreEvictionPolicy="LFU"
          transactionalMode="off"&gt;
          &lt;persistence strategy="localTempSwap" /&gt;
      &lt;/cache&gt;
  
  &lt;/ehcache&gt;
  </code></pre>
  
  <p>I have the following entries in my <code>root-context.xml</code>:</p>
  
  <pre><code>&lt;!-- EhCache Configuration  --&gt;
  &lt;bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:configLocation="classpath:ehcache.xml" p:shared="true"/&gt;
  &lt;bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cacheManager-ref="ehcache"/&gt;
  </code></pre>
  
  <p>And I have a method for which I want to enable ehCache:</p>
  
  <pre><code>@Cacheable(value="swcmRestData", key="url")
  public &lt;T&gt; T getEntity(String url, java.lang.Class&lt;T&gt; gt) throws RestException
  {
      T t = restClientService.getEntity(url, gt);
      return t;
  }
  </code></pre>
  
  <p>I want the data to be retrieved from the ehCache if the same <code>url</code> is passed to the specified method. I do not get any errors while running the code. But looks like the caching is not working. Is there anything that I am missing here</p>