2
您好我正在我的應用程序中實現基於註釋的ehcache。我正在服務層上實現這一點,我使用DetachedCriteria進行查詢,但ehcache無法正常工作。任何人都可以對此有所瞭解嗎?請幫我或建議我採取其他方式來做到這一點。預先 感謝ehcache不工作
在ehcache.xml中
<defaultCache eternal="true" maxElementsInMemory="100" overflowToDisk="false" />
<cache name="loadAll" maxElementsInMemory="1000" eternal="true" overflowToDisk="false" />
</ehcache>
上服務層我使用
@Cacheable(cacheName="loadAll")
List<ShiftDetail> loadAll(DetachedCriteria detachedCriteria);
和在applicationContext.xml中ehcache的被映射爲
<ehcache:annotation-driven create-missing-caches="true" cache-manager="cacheManager" />
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" >
<property name="configLocation" value="/WEB-INF/ehcache.xml"/>
</bean>
也許你可以顯示你的代碼?我用ehcache做了一點,但是我不能像字母表那樣反芻。考慮點擊你的問題上的**編輯**並添加一些相關的代碼和配置。這將給我們一些背景和一些工作。祝你好運! – jmort253
嗨拉曼,你解決了這個問題嗎?我有你的同樣的問題,我有點痛苦。每次我調用metodh時,都不會創建緩存實例。這是我的問題:http://stackoverflow.com/questions/11194982/spring-annotation-cache-cachedecoratorfactory-not-configured-for-defaultcache –
什麼你想要緩存? – Anubhab