我是 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)
任何想法如何让兵马俑工作?