博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用spring-data-redis操作Redis集群
阅读量:7018 次
发布时间:2019-06-28

本文共 2152 字,大约阅读时间需要 7 分钟。

hot3.png

1. Maven依赖

注:spring-data-redis版本要大于1.7

junit
junit
4.12
test
org.springframework
spring-test
4.3.4.RELEASE
test
org.springframework
spring-context
4.3.4.RELEASE
org.springframework.data
spring-data-redis
1.7.5.RELEASE
redis.clients
jedis
2.8.2

2.Spring配置文件

3.Java调用

import org.junit.Assert;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.data.redis.core.RedisTemplate;import org.springframework.test.context.ContextConfiguration;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration("classpath:ApplicationContext.xml")public class RedisTest {    @Autowired    private RedisTemplate
redisTemplate; @Test public void testSetValue() { redisTemplate.opsForValue().set("test1", "hello"); Assert.assertEquals("hello", redisTemplate.opsForValue().get("test1")); }}

转载于:https://my.oschina.net/u/2306705/blog/818976

你可能感兴趣的文章
一次关于runloop的纠错探索之旅
查看>>
npm常用库
查看>>
Golang之变量去哪儿?
查看>>
Vue项目常见问题汇总
查看>>
java多线程总结
查看>>
实现一键式自动化操作(快速创建 Python 与 Shell 文件)
查看>>
9102年:从0开始手写一个Vue.js优化版脚手架
查看>>
[译] Flutter 的 Heroes 和 Villains —— 为 Flutterverse 带来平衡
查看>>
Python进阶之面向对象(类的特殊方法)
查看>>
深入剖析浏览器缓存策略
查看>>
详解Java线程安全
查看>>
Mars - 又双叒叕一个多端开发框架?这次是 Vue 驱动,能完美适配 H5
查看>>
teamview 被检测到商业用途
查看>>
AMP项目实战分享
查看>>
spring security 中解密时如何解密的?
查看>>
(JS基础)Promise 对象
查看>>
以太坊联盟链quorum搭建遇到的问题
查看>>
Xcode可删除文件列表
查看>>
百度UEditor编辑器修改默认字体、字号
查看>>
Mybatis之接口编程--JAVA动态代理的最佳展现
查看>>