gpt4 book ai didi

java - Terracotta 工具包缺少类会阻止 EHCache 启动

转载 作者:行者123 更新时间:2023-12-01 14:44:07 27 4
gpt4 key购买 nike

我是 EHCache 新手,并尝试将其用作我们的缓存服务器。我编写了尝试开始的代码:

public class CacheMap {
private static CacheManager cacheManager=new CacheManager("ehcache.xml");
private static Cache cache=cacheManager.getCache("firstCache");
}

在类路径中,我包含了 terracotta-toolkit-1.6-5.2.0.jar、terracotta-toolkit-1.6-runtime-5.0.0、slf4j-api-1.6.6、slf4j-jdk14-1.6.6、ehcache -2.7.0和ehcache-ee-2.7.0

我的根目录中有 ehcache.xml。

但是,我的代码第一行出现以下错误:

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: net.sf.ehcache.CacheException: Could not create ClusteredInstanceFactory due to missing class. Please verify that terracotta-toolkit is in your classpath.
at net.sf.ehcache.terracotta.TerracottaClusteredInstanceHelper.newClusteredInstanceFactory(TerracottaClusteredInstanceHelper.java:187)
at net.sf.ehcache.terracotta.TerracottaClient.createNewClusteredInstanceFactory(TerracottaClient.java:169)
at net.sf.ehcache.terracotta.TerracottaClient.createClusteredInstanceFactory(TerracottaClient.java:126)
at net.sf.ehcache.CacheManager.doInit(CacheManager.java:442)
at net.sf.ehcache.CacheManager.init(CacheManager.java:392)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:291)
at CacheMap.<clinit>(CacheMap.java:7)

有什么想法可以让 Terracotta 工作吗?

最佳答案

我认为您已经混合了所需的陶 jar 。如果你使用maven,这里是terracotta版本的依赖项。 3.6.5(兼容JDK5的最后一个版本):

<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core-ee</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-terracotta-ee</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.terracotta</groupId>
<artifactId>terracotta-toolkit-1.5-runtime-ee</artifactId>
<version>4.5.0</version>
</dependency>

另外,不要忘记指向 terracotta 的 maven 存储库来下载所需的 jar:

<repository>
<id>terracotta-repository</id>
<url>http://www.terracotta.org/download/reflector/releases</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>

如果您不使用 Maven,那么您的类路径上应该有以下 jar:

  • ehcache-core-ee-2.5.6.jar
  • ehcache-terracotta-ee-2.5.6.jar
  • terracotta-toolkit-1.5-runtime-ee-4.5.0.jar

关于java - Terracotta 工具包缺少类会阻止 EHCache 启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15637680/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com