日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術(shù)文章
文章詳情頁

Spring如何基于注解配置使用ehcache

瀏覽:111日期:2023-08-04 15:56:19

使用ehcache-spring-annotations使得在工程中簡單配置即可使用緩存

下載地址:http://code.google.com/p/ehcache-spring-annotations/

需要的jar包,首先需要的是我們之前做SpringMVC時(shí)的各個(gè)Spring的jar包

然后需要把ehcache-spring-annotations-1.2.0文件夾內(nèi)lib內(nèi)的,非spring的jar加進(jìn)去,因?yàn)槲覀円呀?jīng)增加了我們版本的spring然后還需要?jiǎng)討B(tài)代理的cglib包

在spring主配置文件中配置ehcache注解的使用:

<?xml version='1.0' encoding='UTF-8'?> <beans xmlns='http://www.springframework.org/schema/beans' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:mvc='http://www.springframework.org/schema/mvc' xmlns:p='http://www.springframework.org/schema/p' xmlns:context='http://www.springframework.org/schema/context' xmlns:aop='http://www.springframework.org/schema/aop' xmlns:tx='http://www.springframework.org/schema/tx' xmlns:ehcache='http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring' xsi:schemaLocation='http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd'> <ehcache:annotation-driven cache-manager='ehCacheManager' /> <bean class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'> <property name='configLocation' value='classpath:ehcache.xml'/> </bean> <bean class='test.CacheService'></bean> </beans>

配置緩存配置文件ehcache.xml,改文件放在SRC下:

<?xml version='1.0' encoding='UTF-8'?> <ehcache xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://ehcache.org/ehcache.xsd' updateCheck='false'> <diskStore path='java.io.tmpdir' /> <defaultCache eternal='false' maxElementsInMemory='1000' overflowToDisk='false' diskPersistent='false' timeToIdleSeconds='0' timeToLiveSeconds='600' memoryStoreEvictionPolicy='LRU' /> <cache name='testCache' eternal='false' maxElementsInMemory='100' overflowToDisk='false' diskPersistent='false' timeToIdleSeconds='0' timeToLiveSeconds='300' memoryStoreEvictionPolicy='LRU' /> </ehcache>

CacheService是示例類,代碼如下:

package test; import java.util.Date; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.googlecode.ehcache.annotations.Cacheable; import com.googlecode.ehcache.annotations.TriggersRemove; public class CacheService{ @SuppressWarnings('deprecation') @Cacheable(cacheName = 'testCache') public String getName(String code){ System.out.println('查詢編號(hào):' + code); return new Date().toLocaleString() + '-->' + code; } @SuppressWarnings('deprecation') @Transactional(propagation = Propagation.REQUIRED) public String update(String code){ System.out.println('更新編號(hào):' + code); return new Date().toLocaleString() + '-->' + code; } @TriggersRemove(cacheName='testCache',removeAll=true) public void flush(){ System.out.println('情況緩存'); System.out.println('Processing testFlushing'); } }

改類包含根據(jù)參數(shù)獲取緩存值,更新緩存,情況緩存,都是使用注解標(biāo)簽實(shí)現(xiàn)。

Action類需要改動(dòng)一下,代碼如下:

package test; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; // http://localhost:8080/spring/hello.do?key=1&code=java @org.springframework.stereotype.Controller public class HelloController{ private CacheService sacheService; @SuppressWarnings('deprecation') @RequestMapping('/hello.do') public String hello(HttpServletRequest request,HttpServletResponse response){ String key = request.getParameter('key'); if('1'.equals(key)){ request.setAttribute('message', sacheService.getName(request.getParameter('code'))); }else if('2'.equals(key)){ request.setAttribute('message', sacheService.update(request.getParameter('code'))); }else{ sacheService.flush(); request.setAttribute('message', sacheService.getName(request.getParameter('code'))); } return 'hello'; } public CacheService getSacheService() { return sacheService; } @Autowired public void setSacheService(CacheService sacheService) { this.sacheService = sacheService; } }

根據(jù)key做不同的操作,然后分別訪問以下幾個(gè)路徑,為了方便看效果和學(xué)習(xí),我把工程代碼放到了附件:

第一次沒有緩存http://localhost:8080/spring/hello.do?key=1&code=java讀取緩存http://localhost:8080/spring/hello.do?key=1&code=java更新緩存http://localhost:8080/spring/hello.do?key=2&code=java讀取最新緩存http://localhost:8080/spring/hello.do?key=1&code=java情況緩存http://localhost:8080/spring/hello.do?key=3

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Spring
相關(guān)文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
一区二区三区国产盗摄| 国产精品欧美一区二区三区不卡| 国产精品久久久久久久久免费高清 | 日本一区二区高清不卡| 国产精品日本一区二区不卡视频 | 亚欧成人精品| 亚洲欧美日本国产专区一区| 香蕉视频成人在线观看| 99国产精品久久久久久久| 亚洲欧美日韩在线观看a三区| 国产精品女主播一区二区三区| 国产精品女主播一区二区三区| 亚洲深夜福利| 亚洲精品欧美| 国产精品毛片久久久| 开心激情综合| 伊人久久视频| 黑丝一区二区三区| 蜜臀久久99精品久久久久久9| 美女久久一区| 欧美日韩午夜| 美女视频黄免费的久久| 国产一区二区三区久久| 久久国产欧美| 视频一区视频二区中文字幕| 91麻豆精品| 福利一区和二区| 久久久久久美女精品| 久久福利精品| 国产探花在线精品一区二区| 精品国产日韩欧美精品国产欧美日韩一区二区三区 | 国产成人久久| 免费黄色成人| 亚洲精品乱码| 精品亚洲a∨| 日韩毛片在线| 综合在线一区| 久久久免费人体| 99久久精品国产亚洲精品| 蜜芽一区二区三区| 国内精品亚洲| 亚洲v在线看| 日本伊人午夜精品| 国语精品一区| 99视频一区| 日本精品在线播放| 裤袜国产欧美精品一区| 中文一区一区三区免费在线观 | 国产欧美日韩在线观看视频| 肉色欧美久久久久久久免费看| 日韩在线一二三区| 欧美a级一区二区| 黑丝一区二区三区| 国产精品伦一区二区| 激情久久久久久| 日本99精品| 欧美二区视频| 精品国产一区二区三区性色av| 欧美日韩国产传媒| 免费在线观看一区| 在线视频日韩| 国际精品欧美精品| 日韩欧美激情| 欧美成人亚洲| 激情综合婷婷| 亚洲精品第一| 久久久久久久久丰满| 欧美一区不卡| 久久一区二区三区电影| 国产欧美自拍一区| 国产亚洲在线| 亚洲免费福利| 国产九一精品| 国产精品婷婷| 欧美久久天堂| 国产精品一区二区三区美女 | 久久激情婷婷| 麻豆免费精品视频| 亚洲人亚洲人色久| 久久国产中文字幕| 久久尤物视频| 青青草国产精品亚洲专区无| 国产精品普通话对白| 欧美天堂视频| 欧美激情一区| 日本久久二区| 美女91精品| 欧美精品高清| 欧美激情aⅴ一区二区三区| 中文无码日韩欧| 欧美+日本+国产+在线a∨观看| 欧美国产视频| 日本麻豆一区二区三区视频| 伊人久久大香线蕉av超碰演员| 日本一区二区免费高清| 国产精品毛片视频| 欧美亚洲三级| 日本不卡的三区四区五区| 99在线观看免费视频精品观看| 欧美日韩国产v| 中文字幕人成乱码在线观看| 国产精品qvod| 日韩中文av| 亚洲综合二区| 亚洲国产成人精品女人| 久久久水蜜桃av免费网站| 91亚洲自偷观看高清| 国产精品毛片久久久| 日本一区福利在线| 视频一区欧美日韩| 香蕉久久夜色精品国产| 亚洲一区区二区| 国产精品免费看| 国产视频一区在线观看一区免费| 1024精品一区二区三区| 99精品在线免费在线观看| 日韩精品网站| 五月激情久久| 久久久久国产精品一区二区| 日韩一区二区三区免费| 日韩国产在线| 特黄特色欧美大片| 群体交乱之放荡娇妻一区二区| 国产aa精品| 精品一区二区三区中文字幕| 美女视频黄久久| 国产一区二区三区四区二区| 精品一区电影| 国产精品国产一区| 91视频一区| 欧美日中文字幕| 影音国产精品| 蜜臀av国产精品久久久久| 视频一区在线视频| 免费不卡在线观看| 日韩一区二区三区精品| 777久久精品| 国产精品大片| 超级白嫩亚洲国产第一| 日韩精品久久久久久久电影99爱| 99久久久久| 欧美综合国产| 日本va欧美va瓶| 国产精品密蕾丝视频下载| 精品一区二区三区免费看| 精品国产免费人成网站| 欧美1区免费| 亚洲少妇诱惑| 亚洲欧洲美洲国产香蕉| 国产麻豆精品| 日本在线高清| 美女尤物久久精品| 国产日韩欧美三级| 成人污污视频| 在线日韩一区| 最近国产精品视频| 精品不卡一区| 国产一区二区三区自拍| 日韩中文字幕亚洲一区二区va在线| 日产欧产美韩系列久久99| 精品亚洲a∨一区二区三区18| 欧美一级精品| 综合在线一区| 国产高清视频一区二区| 日韩深夜视频| 蜜臀av亚洲一区中文字幕| 麻豆一区二区三| 亚州av乱码久久精品蜜桃| 亚洲精品观看| 91视频精品| 久久亚洲一区| 欧美国产先锋| 伊人久久婷婷| 国产精品v一区二区三区| 成人精品天堂一区二区三区| 中文视频一区| 国产精品99一区二区三区| 91成人精品| 日本中文字幕视频一区| 狠狠久久伊人| 免费在线观看日韩欧美| 精品国产一区二区三区性色av| 自由日本语亚洲人高潮| 国产精品中文字幕制服诱惑| 另类中文字幕国产精品| 日本视频中文字幕一区二区三区| 日韩综合精品| 日韩av中文字幕一区| 在线一区av| 69精品国产久热在线观看| 久久国产成人午夜av影院宅| 日韩高清一区二区| 99成人在线视频| 7777精品| 夜夜精品视频| 日韩欧美1区| 国产精品嫩模av在线| 国产精品毛片在线看| 国产在线观看www| 日韩1区2区3区|