看得觉得不错,所以试了一下,记一下
要有:
springframework.aop 3.1m2
springframework.context 3.1m2
springframework.aspects 3.1m2
和一个
aopalliance-1.0.jar
这个spring的文档里没提,本来以为有spring的包就行了
配置文件applictionContext-cache.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<cache:annotation-driven />
<!-- generic cache manager -->
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
<set>
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="default"/>
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="books"/>
</set>
</property>
</bean>
</beans>
只是从原例子上抄的,以后可以自己改
这次想缓存的是DAO类的一个方法,试想如果是hibernate,应该不用在这儿进行缓存吧。
@Cacheable(value="books",key="#checkonworkattendance.getAttendanceYear()+#checkonworkattendance.getAttendanceMonth()")
public List viewCheckonworkattendance(
Checkonworkattendance checkonworkattendance)
throws CheckonworkattendanceException {
这里遇到的问题是,尽量使用某一数值为key,否则可能是以OBJECT.toString的方式来作为key, 这样就可能缓存method了。
KEY可以用所谓SpEL方式写,我也就是试写了一个吧,要多个参数组合。
试验时,在类内做断点,只运行一次,再运行时会自动跳过,从cache中取了。
这样对于非hibernate的简易查询,也可以在数据层面进行缓存了。
另,没看到除了annotation方式外的配置方法,因为是想对原有代码进行AOP方式的调教,所以如果能以antmatcher的**方式进行配置就好了。再看
分享到:
相关推荐
Spring 3.1 jar包Spring 3.1 jar包Spring 3.1 jar包Spring 3.1 jar包Spring 3.1 jar包
spring相关配置资料,几乎在里面。包括spring-aop-3.1等文件。
Spring 3.1的 源码,在IDE中关联即可查看框架源码
spring3.1完整包
NULL 博文链接:https://laiahu.iteye.com/blog/1912975
直接引用struct2.3+spring3.1+mybits3.1 核心Jar包和配置文件即可使用
Spring3.1AOP简单例子,需要的jar包分开上传了
spring3.1最新版本的开发宝典,内容详解!
Spring 3.1倚赖的外部jar包汇总
spring3.1官方所有的jar包 org.springframework.aop-3.1.RELEASE.jar org.springframework.asm-3.1.RELEASE.jar org.springframework.aspects-3.1.RELEASE.jar org.springframework.beans-3.1.RELEASE.jar org....
Spring3.1 定时器配置所需jar包-文档-xml配置-class类-maven-IDEA
spring3.1需要的jar包,自身实验过,调试过程序可以正常运行
此包为本人亲测spring3.1所需的全部jar包
spring3.1+xfire1.26 全注解
最新的spring3.1 jar包都在里面,很齐全了!!!
spring3.1+hibernate4.1+struts2整合所有jar包
springMVC3.1 +mybatis3.1集成,包括事务,jqueryEasyUI分页,json,数据库连接池等。环境使用eclipse4.3+maven3.0.5+tomcat7
Spring3.1 MongoDB整合实例(含jar包)已测
spring3.1源码 !
Spring 是一个开源框架,是为了解决企业应用程序开发复杂性而创建的。框架的主要优势之一就是其分层架构,分层架构允许您选择使用哪一个组件,同时为 J2EE 应用程序开发提供集成的框架