創建的Ehcache緩存中讀取的Javadoc EhCacheManagerFactoryBean和EhCacheFactoryBean我想通:問題從春天
<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" />
哪個版本的spring? – skaffman 2010-01-14 08:11:31
這是3.0.0.RELEASE – 2010-01-14 10:22:53
你需要3.1來使用hecache! – 2012-06-08 21:38:41