也不报错 可是整合进去 也没效果。
ehcache 配置
<?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"> <!-- service 缓存配置 --> <cache name="serviceCache" eternal="false" maxElementsInMemory="100" overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0" timeToLiveSeconds="300" memoryStoreEvictionPolicy="LRU" /> </ehcache>
springmvc 部分关于缓存的配置
<!-- 开启ehcache注解 -->
<cache:annotation-driven cache-manager="cacheManager"/>
<!-- ehcache 配置文件读取 -->
<bean id="cacheManagerFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache.xml" />
</bean>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="cacheManagerFactory"/>
</bean>
service 层的注解 我是不是注解用的不对啊
@Cacheable({"list"})
public List<String> getGzhList() {
System.out.println("查询数据库");
List<String> list= gzhMapper.getGzhByList();
return list;
}
这样整合以后 第一次请求 会查询数据库, 可是 第二次 还是去查询数据库了。
请各位大神 给点提示 感激不尽. 豆子不多 略表心意.
已经换了一种方式 了