title: Spring Cache not working for abstract classes
body: <p>I'm trying to use Spring Cache within abstract classes but it won't work, because, from what I can see, Spring is searching for CacheNames on the abstract class. I'm having a REST API which uses a service layer and a dao layer. The idea is to have a different cache name for every subclass.</p>
  
  <p>My abstract service class looks like this:</p>
  
  <pre><code>    @Service
      @Transactional
      public abstract class AbstractService&lt;E&gt; {
  
  ...
  
      @Cacheable
      public List&lt;E&gt; findAll() {
          return getDao().findAll();
      }
  }
  </code></pre>
  
  <p>An extension of the abstract class would look like this:</p>
  
  <pre><code>@Service
  @CacheConfig(cacheNames = "textdocuments")
  public class TextdocumentsService extends AbstractService&lt;Textdocuments&gt; {
  ...
  }
  </code></pre>
  
  <p>So when I start the application with this code, Spring gives me the following exception:</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: No cache names could be detected on 'public java.util.List foo.bar.AbstractService.findAll()'. Make sure to set the value parameter on the annotation or declare a @CacheConfig at the class-level with the default cache name(s) to use.
      at org.springframework.cache.annotation.SpringCacheAnnotationParser.validateCacheOperation(SpringCacheAnnotationParser.java:240) ~[spring-context-4.1.6.RELEASE.jar:?]
  </code></pre>
  
  <p>I think this happens because Spring is searching for the CacheName on the abstract class, despite it is being declared on the subclass. </p>
  
  <p>Trying to use</p>
  
  <pre><code> @Service
   @Transactional
   @CacheConfig
          public abstract class AbstractService&lt;E&gt; {
      }
  </code></pre>
  
  <p>leads to the same exception; using </p>
  
  <pre><code> @Service
   @Transactional
   @CacheConfig(cacheNames = "abstractservice")
          public abstract class AbstractService&lt;E&gt; {
      }
  </code></pre>
  
  <p>gives no exception, but then Spring Cache uses the same cache name for every subclass and ignores the cache name defined on the subclass. Any Ideas to so solve this?</p>