EhCache integration within Spring
Case
You have to use a EhCache in a couple of beans, instancied via Spring.
Fix
In your main Spring configuration file, declare the following block:
<bean id="customCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="shared" value="false" /> <property name="cacheManager"> <bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation" value="classpath*:ehcache.xml" /> </bean> </property> <property name="cacheName" value="SampleConfigOne" /> </bean>
Then, in any of your beans, declare the following property:
<property name="cache" value="customCache"/>