我是 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 一样工作?
最佳答案
就像许多其他大型框架(如 Spring)一样,ehcache 被分成几个模块。其中一个模块是核心模块,其他模块是 Web、服务器、jcache、调试器等等(参见 https://mvnrepository.com/artifact/org.ehcache.modules)。
有时,出于各种原因,您可能不想将整个大型框架及其所有子库包含到您的项目中。然后您可以决定要使用哪个模块。
换句话说,使用ehcache
pom 将在您的项目中包含一个完整的库。使用 ehcache-core
将仅包含 ehcache-core
中定义的功能。
您可以找出哪个模块包含您需要的功能并包含它,或者使用完整的 ehcache 但使用适当的版本。
关于java - ehcache 和 ehcache-core 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17444721/