这篇文章给大家介绍使用spring 实现缓存的方法有哪些,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。1、 spring和ehcache集成主要获取ehcache作为操作ehcache的对象。spring.xml中注入
这篇文章给大家介绍使用spring 实现缓存的方法有哪些,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
1、 spring和ehcache集成
主要获取ehcache作为操作ehcache的对象。
spring.xml中注入ehcacheManager和ehCache对象,ehcacheManager是需要加载ehcache.xml配置信息,创建ehcache.xml中配置不同策略的cache。
<!-- ehCache 配置管理器 --><bean id="ehcacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"><property name="configLocation" value="classpath:ehcache.xml" /><!--true:单例,一个cacheManager对象共享;false:多个对象独立 --><property name="shared" value="true" /><property name="cacheManagerName" value="ehcacheManager" /></bean> <!-- ehCache 操作对象 --><bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"><property name="cacheManager" ref="ehcacheManager"/></bean><!-- 启用缓存注解功能(请将其配置在Spring主配置文件中) --><cache:annotation-driven cache-manager="cacheManager"/>
--结束END--
本文标题: 使用spring 实现缓存的方法有哪些
本文链接: https://www.lsjlt.com/news/223188.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0