小编Tom*_* Ng的帖子

Ehcache 与 Spring 未配置 CacheDecoratorFactory

我正在使用 Spring 项目实现 ehcache 但没有成功。

这是我在 applicationContext.xml 中的设置:

<ehcache:annotation-driven />
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
    <property name="configLocation" value="/META-INF/spring/ehcache.xml" />
</bean>
Run Code Online (Sandbox Code Playgroud)

这是我在 ehcache.xml 中的设置:

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">    

    <diskStore path="java.io.tmpdir" /> 
    <defaultCache eternal="true" maxElementsInMemory="100" overflowToDisk="false" />
    <cache name="listTop" maxElementsInMemory="10" eternal="true" overflowToDisk="false" />

</ehcache>
Run Code Online (Sandbox Code Playgroud)

这是我的实现类:

@Cacheable(cacheName="listTop")
public void listTop(News news, String regionCode, Integer count, Integer categoryId, String listType){
//code here//
}
Run Code Online (Sandbox Code Playgroud)

我收到以下消息,似乎未配置缓存:

1827 DEBUG net.sf.ehcache.config.BeanHandler  - Ignoring ehcache attribute xmlns:xsi
1827 DEBUG net.sf.ehcache.config.BeanHandler  - Ignoring ehcache attribute xsi:noNamespaceSchemaLocation
1828 DEBUG net.sf.ehcache.config.DiskStoreConfiguration  - Disk Store Path: …
Run Code Online (Sandbox Code Playgroud)

java spring ehcache

6
推荐指数
1
解决办法
6658
查看次数

标签 统计

ehcache ×1

java ×1

spring ×1