EhCache
notes for spring boot 1.X + EhCache 3.0 Spring 4
create CacheConfig.jave for the annotation @EnableCaching, @Configuration
spring-bootstrap.xml add xmlns:cache to beans. add <cache:annotation-driven /> for creating beans.
application.properities add one attribute spring.cache.jcache.config=classpath:ehcache.xml
add ehcache.xml: in the xml, eg:
<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3' xmlns:jsr107='http://www.ehcache.org/v3/jsr107'>
<service>
<jsr107:defaults enable-statistics="true" />
</service>
<cache alias="vcmmCache">
<expiry>
<ttl unit="seconds">10</ttl>
</expiry>
<resources>
<heap unit="entries">2000</heap>
<offheap unit="MB">100</offheap>
</resources>
</cache>
<cache alias="vcmmCacheMarket">
<resources>
<heap unit="entries">2000</heap>
<offheap unit="MB">100</offheap>
</resources>
</cache>
</config>
<resources> is needed for creating CacheManager, also <key-type>, <value-type> are not necessary.
jsr107 works for Spring 4 not Spring 3.
Last updated
Was this helpful?