Spring 4+ with Ehcache 3 – how to

  • Postat în IT
  • la 26-01-2017 10:53
  • de Horatiu Dan
  • 556 vizualizări

Once a year, the main project I am working at gets upgraded to use newer versions of its dependencies. Nothing special, just keeping up with the open source industry. Briefly, the project is a Java web application, build upon the Spring Framework. This post will describe how we “managed” to increase the version of Ehcache from 2 to 3, while on Spring Framework 4.3.5 (no Spring Boot). I quoted managed, because what was supposed to be an easy normal task proved to be pretty difficult one.

The caching in the application is implemented using Spring caching abstraction with the specific annotations (@Cachable, @CachePut, @CacheEvict etc.). The aim was to keep the current implementation and just to upgrade the versions and prepare for future improvements (JSR-107 etc.).

For a better understanding, I will first present the current configuration (Ehcache 2) and then the new one (Ehcache 3).

pom.xml

<dependency> <groupId>net.sf.e...