15

我是 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 一样工作?

4

2 回答 2

4

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

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

换句话说,使用ehcachepom 将在您的项目中包含一个完整的库。使用ehcache-core将仅包括ehcache-core.

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

于 2013-07-03T09:54:53.743 回答
1

版本 2.5.7 中仍然有一个ehcache 模块,但由于它只提取依赖项,因此它是 pom 类型的。这些依赖项之一是ehcache-core. 我的猜测是,您的功能不会满足于此。尝试

<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>2.5.7</version>
    <type>pom</type>
</dependency>
于 2013-07-03T09:57:04.207 回答