title: Unable to use Spring @Cacheable and @EnableCaching
body: <p>I'm trying to replace my old:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Component
  public interface MyEntityRepository extends JpaRepository&lt;MyEntity, Integer&gt; {
  
      @QueryHints({@QueryHint(name = CACHEABLE, value = "true")})
      MyEntity findByName(String name);
  }
  </code></pre>
  
  <p>by this: </p>
  
  <pre class="lang-java prettyprint-override"><code>@Component
  public interface MyEntityRepository extends JpaRepository&lt;MyEntity, Integer&gt; {
  
      @Cacheable(value = "entities")
      MyEntity findByName(String name);
  }
  </code></pre>
  
  <p>Because I want to use advanced caching features like no caching of null values, etc.</p>
  
  <p>To do so, I followed Spring tutorial <a href="https://spring.io/guides/gs/caching/">https://spring.io/guides/gs/caching/</a></p>
  
  <p>If I don't annotate my Application.java, caching simply doesn't work.</p>
  
  <p>But if I add <code>@EnableCaching</code> and a CacheManager bean:</p>
  
  <pre class="lang-java prettyprint-override"><code>package my.application.config;
  
  @EnableWebMvc
  @ComponentScan(basePackages = {"my.application"})
  @Configuration
  @EnableCaching
  public class Application extends WebMvcConfigurerAdapter {
  
      @Bean
      public CacheManager cacheManager() {
          return new ConcurrentMapCacheManager("entities");
      }
  
  // ...
  }
  </code></pre>
  
  <p>I get the following error at startup:</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: No CacheResolver specified, and no bean of type CacheManager found.  Register a CacheManager bean or remove the @EnableCaching annotation from your configuration</p>
  </blockquote>
  
  <p>I get the same error if I replace My CacheManager bean by a CacheResolver bean like:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Bean
  public CacheResolver cacheResolver() {
      return new SimpleCacheResolver(new ConcurrentMapCacheManager("entities"));
  }
  </code></pre>
  
  <p>Do I miss something ?</p>