How To Load Ehcache.xml From External Location Spring Boot? – Quick & Easy Solution In 2 Mins!

You are currently viewing How To Load Ehcache.xml From External Location Spring Boot? – Quick & Easy Solution In 2 Mins!
Photo by Nick Morrison on Unsplash
Share This Post, Help Others, And Earn My Heartfelt Appreciation! :)

In this tutorial we will focus on how to load ehCache.xml from external location Spring Boot. Out of the box the ehCache is looking for the ehCache.xml configuration file in resources path which is packed into jar file. In case when you want to use external ehCache.xml configuration file to can use the VM options and pass there appropriate value.

Whait is Ehcache?

Ehcache is an open source, standards-based cache that boosts performance, offloads your database, and simplifies scalability. It’s the most widely-used Java-based cache because it’s robust, proven, full-featured, and integrates with other popular libraries and frameworks. Ehcache scales from in-process caching, all the way to mixed in-process/out-of-process deployments with terabyte-sized caches.

Load ehcache.xml from external location Spring Boot

The most important part is the “file:” prefix before the path. Without it the application will looking for the configuration file in the classpath.


Ehcache Spring Boot Configuration

Use the EhCache Spring Boot below exmple:


Ehcache 3.10 is now available!

The major feature in this release is addition of new variant JARs that adopt the Jakarta EE namespaced JTA and JAXB APIs.

It requires Java 8+.

Watch for continued rapid improvements to features, stability and performance of the 3.x line throughout the coming months!As a reminder, Ehcache 3 introduced the following:

  • Revamped API that leverages Java generics and simplifies Cache interactions,
  • Full compatibility with javax.cache API (JSR-107),
  • Offheap storage capabilities, including offheap only caches,
  • Out of the box Spring Caching and Hibernate integration thanks to the javax.cache support,
  • And many more …

“Official” builds are available on the project’s GitHub release page or from Maven Central – see below.

If you enjoyed this post please add the comment below and share this post on your Facebook, Twitter, LinkedIn or another social media webpage.
Thanks in advanced!

How useful was this post?

Click on a star to rate it!

Average rating 4.8 / 5. Vote count: 1280

No votes so far! Be the first to rate this post.

Notify of
Inline Feedbacks
View all comments