Java 从spring创建EhCache时出现问题

Java 从spring创建EhCache时出现问题,java,spring,ehcache,Java,Spring,Ehcache,阅读javadoc,我发现: <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:configLocation="classpath:ehcache.xml"/> <bean id="locationCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"

阅读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。(Ljava/lang/String;ILnet/sf/ehcache/store/MemoryStoreReceivectionPolicy;ZLjava/lang/String;ZJZJLnet/sf/ehcache/event/RegisteredEventListeners;Lnet/sf/ehcache/bootstrap/BootstrapCacheLoader;II)V

我试过Ehcache1.7.2、1.6.2和1.5.0

如果我在ehcache.xml中指定
,它就可以工作,但我更喜欢在ApplicationContext.xml中完成配置

<cache name="locationCache" /> 


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

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

哪个版本的spring?您需要3.1才能使用hecache!哪个版本的spring?你需要3.1才能使用hecache!我在类路径上找到了一个旧的ehcache版本(1.2.4)。解决了这个问题。谢谢。我在类路径上找到了一个旧的ehcache版本(1.2.4)。解决了这个问题。谢谢