O'Reilly logo

Mastering Spring Application Development by Anjana Mankale

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Maven dependency for Spring with caching

If you are using Maven as a build tool, ensure that you add the ehcache dependency in the pom.xml file. Below is the Maven dependency for using cache with spring's caching framework:

  <groupId>net.sf.ehcache</groupId>
  <artifactId>ehcache</artifactId>
  <version>2.7.4</version>
</dependency>

Declarative configuration of ehcache

In the following section, we can see how we can configure the cache storage declaratively. The ecache.xml file is as follows:

<ehcache xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true" maxBytesLocalHeap="150M" > <diskStore path="java.io.tmpdir"/> <cache name="searchResults" maxBytesLocalHeap="100M" eternal="false" timeToIdleSeconds="300" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required