ehcache和ehcache-core之间的区别

时间:2013-07-03 09:46:41

标签: java pom.xml ehcache difference

我是Spring框架中ehcache v / s ehcache-core的初学者,我的pom.xml使用了ehcache 1.5.0版本

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

现在,它需要更新ehcache版本,因为它将在另一个jar中使用: - 更新了ehcache 2.7.0版 但它返回错误 找不到net.sf.ehcache.Cache.getStatistics()方法。

现在,我正在通过ehcache-core 2.5.7替换ehcache: -

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

它是否打破了其他功能或与ehcache一样工作?

2 个答案:

答案 0 :(得分:3)

正如许多其他大型框架(如Spring)一样,ehcache被分成几个模块。其中一个模块是核心模块,其他模块是web,服务器,jcache,调试器等等(参见https://mvnrepository.com/artifact/org.ehcache.modules)。

有时,由于各种原因,您可能不希望将整个大型框架及其所有子库包含到项目中。然后,您可以决定要使用哪个模块。

换句话说,使用ehcache pom将在项目中包含一个完整的库。使用ehcache-core只会包含ehcache-core中定义的功能。

您可以找出哪个模块包含您需要的功能并包含它,或者使用完整的ehcache但使用适当的版本。

答案 1 :(得分:1)

仍然有一个ehcache module in version 2.5.7,但由于它只提取依赖关系,因此它类型为pom。其中一个依赖项是ehcache-core。我的猜测是,你的功能不会被这种情况所满足。尝试

<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>2.5.7</version>
    <type>pom</type>
</dependency>