配置Spring Data Redis
事前准备
1、下载redis
https://github.com/MicrosoftArchive/redis/releases/tag/win-3.2.100
2、下载redis可视化工具
https://redisdesktop.com/download
3、启动redis
cd %redis%
redis-server.exe
配置
4、pom.xml追加
spring-data-redis
jedis
5、新建redis/redis.properties
redis.hostname=localhost
redis.port=6379
#redis.password=
6、新建springframework/spring-redis.xml
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"> <context:property-placeholder location="classpath:redis/redis.properties"
ignore-unresolvable="true" /> <bean id="redisConnectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="${redis.hostname}" />
<property name="port" value="${redis.port}" />
</bean> <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="ConnectionFactory" ref="redisConnectionFactory" />
</bean> <bean id="cacheManager"
class="org.springframework.data.redis.cache.RedisCacheManager">
<constructor-arg ref="redisTemplate" />
<property name="defaultExpiration" value="3000" />
</bean> </beans>
8、确保spring-redis.xml能被引入application-context.xml中
<import resource="classpath:springframework/spring-*.xml" />
7、至此,可以通过在ServiceImpl类的方法上追加@Cacheable @CachePut @CacheEvict 来实现缓存了。
配置Spring Data Redis的更多相关文章
- spring data redis jackson 配置,工具类
spring data redis 序列化有jdk .jackson.string 等几种类型,自带的jackson不熟悉怎么使用,于是用string类型序列化,把对象先用工具类转成string,代码 ...
- spring data redis RedisTemplate操作redis相关用法
http://blog.mkfree.com/posts/515835d1975a30cc561dc35d spring-data-redis API:http://docs.spring.io/sp ...
- spring mvc Spring Data Redis RedisTemplate [转]
http://maven.springframework.org/release/org/springframework/data/spring-data-redis/(spring-data包下载) ...
- Spring Data Redis简介以及项目Demo,RedisTemplate和 Serializer详解
一.概念简介: Redis: Redis是一款开源的Key-Value数据库,运行在内存中,由ANSI C编写,详细的信息在Redis官网上面有,因为我自己通过google等各种渠道去学习Redis, ...
- Spring Data Redis—Pub/Sub(附Web项目源码)
一.发布和订阅机制 当一个客户端通过 PUBLISH 命令向订阅者发送信息的时候,我们称这个客户端为发布者(publisher). 而当一个客户端使用 SUBSCRIBE 或者 PSUBSCRIBE ...
- Spring Data Redis—Pub/Sub(附Web项目源码) (转)
一.发布和订阅机制 当一个客户端通过 PUBLISH 命令向订阅者发送信息的时候,我们称这个客户端为发布者(publisher). 而当一个客户端使用 SUBSCRIBE 或者 PSUBSCRIBE ...
- spring data redis 理解
前言 Spring Data Redis project,应用了Spring概念来开发使用键值形式的数据存储的解决方案.我们(官方)提供了一个 "template" ,这是一个高级 ...
- Spring Data Redis 详解及实战一文搞定
SDR - Spring Data Redis的简称. Spring Data Redis提供了从Spring应用程序轻松配置和访问Redis的功能.它提供了与商店互动的低级别和高级别抽象,使用户免受 ...
- Spring Data Redis 让 NoSQL 快如闪电(2)
[编者按]本文作者为 Xinyu Liu,文章的第一部分重点概述了 Redis 方方面面的特性.在第二部分,将介绍详细的用例.文章系国内 ITOM 管理平台 OneAPM 编译呈现. 把 Redis ...
随机推荐
- SVN_04建库
示范加入一个代码库[Repository] [1]点击Repository右键,创建一个新库 (常规FSFS存储库) [2]在下面所看到的文本框中输入库名称 只创建空的库 创建完库后,没有任何内容在里 ...
- eclipse 部署Tomcat 只有web-inf webapps没有项目文件
只有webapps 修改eclipse 默认的 发布位置改为 tomcat的安装位置 eclipse 默认的web-content 改为webroot ,发布后web-inf目录下才会有webroot ...
- js入门之DOM动态创建数据
一. 知识点回顾 1. DOM结构 nodeName: '' 标签名 nodeType: '' 类型 1元素节点 2属性节点 3文本节点 nodeValue: '' 如果是元素节点 nodeValue ...
- FICO-错误日志集
1.F-02报错 System error in routine FI_TAX_CHK_PRICING_DATA error code 13 function builder TAX2 程序 FI_T ...
- Linux Exploit系列之三 Off-By-One 漏洞 (基于栈)
Off-By-One 漏洞 (基于栈) 原文地址:https://bbs.pediy.com/thread-216954.htm 什么是off by one? 将源字符串复制到目标缓冲区可能会导致of ...
- Formal Analysis of the TLS Handshake Protocol -----论文整理
1.关键词 TLS.SSL.Formal Analsysis Conridentiality Secerecy 2.Table THE SSL/TLS handshake Protocol 3 ...
- djangoform表单使用验证码
8.1.安装captcha 直接安装:pip install django-simple-captcha Django自动帮我们安装了相关的依赖库six.olefile和Pillow,其中的Pillo ...
- Tornado框架 源码基本分析
在python2 的环境中 pip install tornado==1.2.1 1.2.1版本Tornado源码少,利于了解. import tornado.ioloop import tornad ...
- /etc/apt/sources.list 和 /etc/apt/sources.list.d
转自:大数据云技术基础之Linux源:/etc/apt/sources.list文件 导读 1./etc/apt/sources.list的作用是什么?2.为什么会产生 /etc/apt/source ...
- Nginx.conf配置文件默认配置块略解
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #erro ...