title: Spring Boot - cache not working, how to set cache up correctly?
body: <p>My application is on Spring boot 1.5.1</p>
  
  <p>I have looked up all common problems related to caching not working in spring boot (calling a cacheable method from the same class, etc) and I still can't seem to pinpoint why my method is not cacheing. I am just trying to use the simple cache built into Spring (ie the concurrent hashmap).</p>
  
  <p>Setup: in pom.xml I added this</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-cache&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>My configuration class is the following:</p>
  
  <pre><code>@SpringBootApplication
  @Configuration
  @EnableCaching
  @EnableScheduling
  public class Application {
      public static void main(String[] args) {
         SpringApplication.run(Application.class, args);
      }
  
  }
  </code></pre>
  
  <p>I have a controller class that has the following method to get a list of versions.</p>
  
  <pre><code> @RequestMapping(value = "/getVersionList", method = RequestMethod.GET)
   public JSONObject getVersionList() {
      JSONObject retJSON = new JSONObject();
      List&lt;String&gt; versions = fetchVersionService.getVersionList();
      retJSON.put("versions", versions);
      return retJSON;
  }
  </code></pre>
  
  <p>And the FetchVersionService class where I have the cacheable method to cache this versions list</p>
  
  <pre><code>@Cacheable("versions")
  public List&lt;String&gt; getVersionList() {
      System.out.println("If there is something in the cache, it should not hit here.");
      return randomService.getVersions(); //another service class that gets versions from a remote location, which takes a long time
  }
  </code></pre>
  
  <p>Whenever I make multiple GET calls to this function, it always goes inside the function even though I only expect to it execute the function once. For some reason it isn't cacheing the results. 
  Any ideas where I went wrong with my setup? Thanks a lot.</p>