我正在以同样的方式使用我以前使用过的 JCS,没有任何问题。
当服务器启动时,我手动设置缓存属性
CompositeCacheManager ccm = CompositeCacheManager.getUnconfiguredInstance();
Properties props = new Properties();
props.put("jcs.default", "");
props.put("jcs.default.cacheattributes", "org.apache.jcs.engine.CompositeCacheAttributes");
props.put("jcs.default.cacheattributes.MaxObjects", "1000");
props.put("jcs.default.cacheattributes.MemoryCacheName", "org.apache.jcs.engine.memory.lru.LRUMemoryCache");
props.put("jcs.default.cacheattributes.UseMemoryShrinker", "true");
props.put("jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds", "3600");
props.put("jcs.default.cacheattributes.ShrinkerIntervalSeconds", "60");
props.put("jcs.default.elementattributes", "org.apache.jcs.engine.ElementAttributes");
props.put("jcs.default.elementattributes.IsEternal", "false");
ccm.configure(props);
以这种方式设置时会引发错误
org.apache.jcs.engine.CompositeCacheAttributes cannot be cast to org.apache.commons.jcs.engine.behavior.ICompositeCacheAttributes
我在其他项目上使用了完全相同的方法,没有问题。为什么我现在得到这个异常?
编辑
我正在从
<dependency>
<groupId>org.apache.jcs</groupId>
<artifactId>jcs</artifactId>
<version>1.3</version>
</dependency>
在此之前,我也尝试过获得同样问题的 2.0-beta 版本
编辑 2
如果其他人面临同样的问题并希望跟随,我已经在 Jira 开了一张票。