EHCache Hello World Example

EHCache Hello World Example

This is a basic example to help you getting start with EHCache. Technologies used in this examples are

  • Ehcache 2.10.2
  • Maven
  • JDK 1.7

1. POM entry to include Ehcache in Maven project

2. Folder structure of the project


3. Basic example of Ehcache


We are done with Hello world application with EhCache. When we are not defining any property file for Ehcache then cache is created with default values. Cache in Ehcache is created with some basic properties which are listed below.

We can change these default values with the help of configuration file. Let us create an ehcache.xml and put it into the src/main/resources folder.

TestClass to check configuration changes


As we can see, now the default parameters of cache is overridden by parameters from configuration file.

Leave a Reply

Your email address will not be published. Required fields are marked *