繁体   English   中英

从春季创建EhCache缓存时出现问题

[英]problem creating an EhCache Cache from spring

阅读EhCacheManagerFactoryBeanEhCacheFactoryBean的javadoc时,我发现:

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:configLocation="classpath:ehcache.xml"/>

<bean id="locationCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"
      p:cacheManager-ref="cacheManager"
      p:cacheName="locationCache"/>

会创建一个我可以@Autowired进入的缓存。但是我必须缺少一些东西,因为这是我得到的:

向类org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException的侦听器实例发送上下文初始化事件的异常:在ServletContext资源[/WEB-INF/applicationContext.xml中定义的名称为'locationCache'的bean创建时出错]:调用init方法失败; 嵌套的异常是java.lang.NoSuchMethodError:net.sf.ehcache.Cache。 Lnet / sf / ehcache / bootstrap / BootstrapCacheLoader; II)V

我已经尝试过ehcache 1.7.2、1.6.2和1.5.0。

如果我在ehcache.xml中指定<cache name="locationCache" /> ,它会起作用,但我希望在appsContext.xml中完成配置

<cache name="locationCache" /> 

缺少的构造函数属于Ehcache 1.3,在新版本中仍然存在。 可能是,您在依赖方面有一些问题。 如果使用maven,请尝试使用mvn dependency:tree -Dverbose=true并查找冲突。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM