跳至主要内容

博文

目前显示的是标签为“Ehcache”的博文

Caching with EhCache

Spring Caching with EhCache Alternatively, you can use Ehcache and use the Ehcache specific   CacheManager   as cache provider. Enable Caching Add   @EnableCaching(mode=AdviceMode.ASPECTJ)   annotation on the configuration class if you are using Java based configuration. @Configuration ... @EnableCaching(mode=AdviceMode.ASPECTJ) public class JpaConfig {...} Then, specify a   CacheManager   provider in your configuration. There is a   EhCacheCacheManager   provided by Spring. @Bean public CacheManager cacheManager() { return new EhCacheCacheManager(ehcache().getObject()); } @Bean public EhCacheManagerFactoryBean ehcache() { EhCacheManagerFactoryBean ehcache = new EhCacheManagerFactoryBean(); //ehcache.setConfigLocation(new ClassPathResource("ehcache.xml")); return ehcache; } Do not forget to add the   ehcache   dependency in your Maven pom.xml file. <dependency> <groupId>net.sf.ehcache</groupId> ...