Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ehcache 3.8.1 still use ehcache.xml for configuration?

Does ehcache 3.8.1 no longer automatically pick up the configuration settings in an ehcache.xml file at the source root directory?

like image 679
Paul Reiners Avatar asked Mar 28 '26 01:03

Paul Reiners


1 Answers

Yes, it's looks so, now it needs to be done using a XML file by configuringe a CacheManager at creation time, according to this schema definition.

XML programmatic parsing

If you are obtaining your CacheManager through the JSR-107 API, what follows is done automatically when invoking javax.cache.spi.CachingProvider.getCacheManager(java.net.URI, java.lang.ClassLoader)

final URL myUrl = getClass().getResource("/configs/docs/getting-started.xml"); 
XmlConfiguration xmlConfig = new XmlConfiguration(myUrl); 
CacheManager myCacheManager = CacheManagerBuilder.newCacheManager(xmlConfig); 
myCacheManager.init();  
  1. Obtain a URL to your XML file’s location
  2. Instantiate an XmlConfiguration passing the XML file’s URL to it
  3. Using the static
org.ehcache.config.builders.CacheManagerBuilder.newCacheManager(org.ehcache.config.Configuration)

allows you to create your CacheManager instance using the Configuration from the XmlConfiguration

  1. Initialize the cacheManager before it is used.

Reference - http://www.ehcache.org/documentation/3.8/xml.html

like image 100
Devesh mehta Avatar answered Apr 03 '26 12:04

Devesh mehta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!