2010-01-13 77 views
0

创建的Ehcache缓存中读取的Javadoc EhCacheManagerFactoryBeanEhCacheFactoryBean我想通:问题从春天

<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但我必须失去了一些东西,因为这是我得到:

Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'locationCache' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: net.sf.ehcache.Cache.(Ljava/lang/String;ILnet/sf/ehcache/store/MemoryStoreEvictionPolicy; ZLjava/lang/String;ZJJZJLnet/sf/ehcache/event/RegisteredEventListeners; Lnet/sf/ehcache/bootstrap/BootstrapCacheLoader;II)V

我试过ehcache 1.7.2,1.6.2和1.5.0。

如果我指定在ehcache.xml中<cache name="locationCache" />但我更喜欢它的工作原理已经我的配置在applicationsContext.xml

<cache name="locationCache" /> 
+0

哪个版本的spring? – skaffman 2010-01-14 08:11:31

+0

这是3.0.0.RELEASE – 2010-01-14 10:22:53

+0

你需要3.1来使用hecache! – 2012-06-08 21:38:41

回答

3

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

+0

我在类路径中找到了一个旧的ehcache版本(1.2.4)。删除解决了这个问题。谢谢。 – 2010-01-14 10:38:45