James Selvakumar opened SPR-14884 and commented
I have a multi module project with all the modules defining their cache configurations in their own ehcache.xml. This use case is addressed by the now unmaintained "ehcache-spring-annotations" project (via a third party cache manager factory) through a configuration like this:
<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>
Basically, ItcbEhCacheManagerFactoryBean merges all the "ehcache.xml" files found in various modules into one stream and effectively creating one cache manager.
Since we would like to migrate to Spring's Cache Abstraction, I tried something similar in Spring
<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"/>
However, I ran into this exception:
Caused by: java.io.FileNotFoundException:
class path resource [classpath*:ehcache.xml] cannot be opened because it does not exist
I checked CompositeCacheManager and unfortunately, it's doesn't address our use-case specified. I personally feel it would be great to have this feature out of the box in Spring.
Reference URL: http://stackoverflow.com/questions/40460488/spring-cache-abstraction-ehcache-integration-in-a-multi-module-project
Comment From: spring-projects-issues
Stéphane Nicoll commented
Thanks for the proposal but we're not keen on supporting this feature. You can easily have that in your own code if merging several ehcache.xml
files is something you want to do.
Comment From: lucasguaycochea
Hi, is there any feature that enables having different xml config files per module and import them all together in the application?
Comment From: snicoll
@lucasguaycochea that's a question for the ehcache team. If they have a programmatic SPI, nothing prevents you from having contributors in each module that you call yourself.