To get annotation-based caching magic for working with Spring, you need to have an ad in xml, for ex...">

Non-XML version <cache: annotation-driven / ">

To get annotation-based caching magic for working with Spring, you need to have an ad in xml, for example: <cache:annotation-driven />

How can I configure a software caching system?

This is what I have. I want to get rid of the @ImportResource and XML file.

 @Configuration @ImportResource("classpath:cache-context.xml") public class DI_EhCache { /** * Create cache object for various cachable methods and add to EhCache Manager. * * @return EhCacheManager */ @Bean EhCacheCacheManager cacheManager() { EhCacheCacheManager ehcm = new EhCacheCacheManager(); CacheManager cm = CacheManager.create(); Cache station = new Cache("station", 1, false, true, 0, 10); cm.addCache(station); ehcm.setCacheManager(cm); return ehcm; } } 
+4
source share
1 answer

Spring 3.1 RC2 added the @EnableCaching annotation, which was missing from RC1. This annotation is the equivalent of <cache:annotation-driven /> and is added to your @Configuration class:

 @Configuration @EnableCaching public class DI_EhCache { 

Rc2 did not seem to be announced, and the documents are not related to the site, but you can download it here and see the documents for @EnableCaching here .

+8
source

Source: https://habr.com/ru/post/1385147/


All Articles