【发布时间】:2019-03-24 07:33:32
【问题描述】:
我使用Ehcache 2 + spring boot。这是我的配置:
@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.
现在我想使用 Ehcache 3 + spring boot 和 Java config 而不是 xml 但我还没有找到任何示例。我的问题:
1) 为什么几乎所有的例子都是基于xml的?这怎么能比 java config 更好?
2) 如何不使用 xml 在 spring boot 中使用 java config 配置 Ehcache 3 >?
【问题讨论】:
-
你看到this?
-
@Patrick 在本文中使用 xml 配置
标签: java spring spring-boot ehcache