15

I am beginner for ehcache v/s ehcache-core in Spring framework, my pom.xml used ehcache version 1.5.0

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

Now, it will need to update ehcache version because it will use in another jar:- Updated ehcache version 2.7.0 But it returns error net.sf.ehcache.Cache.getStatistics() method not found.

Now, I am replacing ehcache via ehcache-core 2.5.7 as:-

<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.5.7</version>
</dependency>

Is it break another functionalities or will work same as ehcache?

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
user2317982
  • 185
  • 1
  • 7

2 Answers2

4

Just as many other large frameworks (like Spring), ehcache is split into several modules. One of those modules is core, the others are web, server, jcache, debugger and many more (see https://mvnrepository.com/artifact/org.ehcache.modules).

Sometimes, for various reasons, you may not want to include the entire large framework, with all its sublibraries, into your project. Then you can decide which module you want to use.

In other words, using ehcache pom will include a full library in your project. Using ehcache-core will only include functionalities defined in ehcache-core.

You can either find out which module contains the functionality you need and include it, or go with full ehcache but use the appropriate version.

Dariusz
  • 21,561
  • 9
  • 74
  • 114
  • 5
    It seems that this answer is outdated now. The `ehcache` artifact contains all that is needed to work with Ehcache. It remains unclear to me what `ehcache-core` may be, and the text on Terracotta’s download page is not helpful either. It seems to me that `ehcache-core` is outdated by now. – Michael Piefel Mar 05 '14 at 11:01
  • `ehcache-core` is not outdated. The latest version 2.6.11 is released in Apr 2014. Its purpose is to pair it with other modules (say `hibernate-ehcache`) for added functionality. – Vinay Dec 02 '15 at 07:10
  • the link is dead (404) – naXa stands with Ukraine Mar 26 '18 at 16:56
  • @MichaelPiefel ehcache core still exists and is still updated, etc. etc. - https://mvnrepository.com/artifact/org.ehcache.modules/ehcache-core/3.5.2 – Dariusz Mar 27 '18 at 06:06
  • @Dariusz: Good to know, thanks for pointing that out. However, I would not say ‘still exists’, but rather ‘exists again’. The artifact has moved from `net.sf.ehcache` to `org.ehcache` for version 3 and has been reorganized. – Michael Piefel Mar 27 '18 at 17:44
  • I would say it is something bit different. ehcache is updated and has recent releases, ehcache-core moved to another package, previous one had release 7 years ago. – Krzysztof Krasoń Feb 14 '22 at 16:06
1

There still is an ehcache module in version 2.5.7 but as it only pulls dependencies it's of type pom. One of those dependencies is ehcache-core. My guess is that your functionality won't be satsified with just that. Try

<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>2.5.7</version>
    <type>pom</type>
</dependency>
André Stannek
  • 7,773
  • 31
  • 52