【发布时间】:2017-03-20 12:28:17
【问题描述】:
我有一个多模块项目,所有模块都在自己的 ehcache.xml 中定义了它们的缓存配置。 现在未维护的“ehcache-spring-annotations”项目通过如下配置解决了这个用例:
<ehcache:annotation-driven cache-manager="ehCacheManager" create-missing-caches="true"/>
<bean id="ehCacheManager" class="net.sf.itcb.addons.cachemanager.ItcbEhCacheManagerFactoryBean">
<property name="configLocations" value="classpath*:ehcache.xml"/>
<property name="shared" value="true"/>
</bean>
我在 Spring 的 Cache Abstraction 中尝试过类似的东西。
<cache:annotation-driven/>
<bean id="cacheManager"
class="org.springframework.cache.ehcache.EhCacheCacheManager"
p:cache-manager-ref="ehcache"/>
<bean id="ehcache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:config-location="classpath*:ehcache.xml"/>
但是,我遇到了这个异常:
Caused by: java.io.FileNotFoundException:
class path resource [classpath*:ehcache.xml] cannot be opened because
it does not exist
谁能解释一下在多模块项目中为 EhCache 配置 Spring 的缓存抽象的正确方法是什么?
【问题讨论】:
-
在 Spring 项目中将此作为issue 提出。
标签: java spring caching ehcache spring-cache