I use Ehcache 2 + spring boot
. Here is my config:
@Bean
public CacheManager cacheManager() {
return new EhCacheCacheManager(ehCacheCacheManager().getObject());
}
@Bean
public EhCacheManagerFactoryBean ehCacheCacheManager() {
EhCacheManagerFactoryBean cmfb = new EhCacheManagerFactoryBean();
cmfb.setConfigLocation(new ClassPathResource("ehcache.xml"));
cmfb.setShared(true);
return cmfb;
}
ehcache.xml - in resources.
Now I want to use Ehcache 3 + spring boot
and Java config instead xml but I haven't found any example for this. My questions:
1) Why almost all examples are based on xml? How can this be better than java config?
2) How can I configure Ehcache 3 using java config in spring boot without using xml?