Announcement Announcement Module
Collapse
No announcement yet.
How to make @Cacheable work for @Controller methods? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to make @Cacheable work for @Controller methods?

    Hi,

    I'm just curious how to make @Cacheable work for Controller methods?

    I have a core/web module project with
    cache:annotation-driven in core/applicationContext.xml

    When I add
    cache:annotation-driven in web/applicationContext.xml

    my @Cacheable methods are not executed.

    I've also tried adding
    PHP Code:
     <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cacheManager-ref="ehcache"/>
        <
    bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" 
            
    p:config-location="classpath:/ehcache.xml"/> 
    to web/applicationContext.xml

    Any ideas?

    Marc

  • #2
    A few days ago i read this note in the official documentation:

    Note
    <cache:annotation-driven/> only looks for @Cacheable/@CacheEvict on beans in the same application context it is defined in. This means that, if you put <cache:annotation-driven/> in a WebApplicationContext for a DispatcherServlet, it only checks for @Cacheable/@CacheEvict beans in your controllers, and not your services.

    http://static.springsource.org/sprin...tml/cache.html

    I expect it helps 'u

    Comment

    Working...
    X