Search
Calendar
April 2024
S M T W T F S
« Sep    
 123456
78910111213
14151617181920
21222324252627
282930  
Your widget title
Archives

PostHeaderIcon 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"/>

Leave a Reply