Skip to content

Instantly share code, notes, and snippets.

@milanboers
Created August 14, 2017 10:57
Show Gist options
  • Save milanboers/9b68b1c38a29556fb83a640eb81df586 to your computer and use it in GitHub Desktop.
Save milanboers/9b68b1c38a29556fb83a640eb81df586 to your computer and use it in GitHub Desktop.
Spring Cache + Ehcache 3 configuration (JCache / JSR107)
@Configuration
@EnableCaching
public class CacheConfiguration {
@Bean
public JCacheManagerFactoryBean cacheManagerFactoryBean() throws Exception {
JCacheManagerFactoryBean jCacheManagerFactoryBean = new JCacheManagerFactoryBean();
jCacheManagerFactoryBean.setCacheManagerUri(new ClassPathResource("ehcache.xml").getURI());
return jCacheManagerFactoryBean;
}
@Bean
public CacheManager cacheManager() throws Exception {
final JCacheCacheManager jCacheCacheManager = new JCacheCacheManager();
jCacheCacheManager.setCacheManager(cacheManagerFactoryBean().getObject());
return jCacheCacheManager;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment