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 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>
I tried something similar in Spring's 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"/>
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
Can someone please explain what is the correct way to configure Spring's Cache Abstraction for EhCache in a multi module project?
In the end, we moved away from ehcache.xml and started using Java based configuration for our caches which solved this problem.