[英]problem creating an EhCache Cache from spring
閱讀EhCacheManagerFactoryBean和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。 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.