ehcache与spring,mybatis整合
2017-07-01 10:45
281 查看
spring
<!-- 配置ehcache -->
<bean id="cacheManagerFactory"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache.xml" />
<property name="shared" value="true" />
</bean>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="cacheManagerFactory" />
</bean>
<!-- 启动ehcache缓存注解 -->
<cache:annotation-driven cache-manager="cacheManager" />
mybatis
不打印日志
<cache type="org.mybatis.caches.ehcache.EhcacheCache"/>
打印日志
<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
@Cacheable(value="user",key="#mobile")
添加缓存 value=缓存名 key=缓存中may的key
@CacheEvict(value="user",allEntries=true)
清除缓存 allEntries=true 清除此缓存中的全部数据
<!-- 配置ehcache -->
<bean id="cacheManagerFactory"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache.xml" />
<property name="shared" value="true" />
</bean>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="cacheManagerFactory" />
</bean>
<!-- 启动ehcache缓存注解 -->
<cache:annotation-driven cache-manager="cacheManager" />
mybatis
不打印日志
<cache type="org.mybatis.caches.ehcache.EhcacheCache"/>
打印日志
<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
@Cacheable(value="user",key="#mobile")
添加缓存 value=缓存名 key=缓存中may的key
@CacheEvict(value="user",allEntries=true)
清除缓存 allEntries=true 清除此缓存中的全部数据
相关文章推荐
- Mybatis(3、延迟加载、查询缓存、与ehcache整合、逆向工程、与spring整合)
- spring+Mybatis+Ehcache整合(Ehcachec参数说明XML配置)
- SSM springmvc mybatis 整合 bootstrap maven shiro druid ehcache SSM
- springmvc+mybatis+shiro+ehcache整合
- spring整合SpringMVC+Mybatis+ehcache+quartz
- spring+Mybatis+Ehcache整合
- Spring+Mybatis+ehcache整合
- spring ,springMVC,Mybatis和ehcache整合遇到的问题
- Spring + MyBatis + Ehcache 整合 CacheManager 版本>2.5,命名空间冲突 解决
- 最近在集成springMVC+mybatis +ehcache 整合碰到了很多坑希望对想了解的同学有一定的帮助
- SpringMVC+MyBatis 整合遇到错误 Configuration problem: Unable to locate Spring NamespaceHandler for XML
- Mybatis与Spring的原生Dao整合
- SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)
- Spring+Struts2+Mybatis整合
- Spring+SpringMVC+MyBatis+easyUI整合基础篇(十二)阶段总结
- springboot+mybatis+ehcache实现缓存数据
- Spring Boot + Mybatis + Ehcache架构基本配置
- spring,mybatis,atomikos多数据源的整合
- Ehcache和Spring整合
- 第一章:Dubbo整合maven+spring+springmvc+mybatis之环境准备