依赖

     <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><!--    测试起步依赖    --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId></dependency><!--    junit    --><dependency><groupId>junit</groupId><artifactId>junit</artifactId><scope>test</scope></dependency>

redis配置application.yml

spring:redis:host: localhostport: 6379connect-timeout: 3000
  • redis包>天翼云盘访问码6nx5

  • 在redis目录里找到redis.conf,搜索有没有"protected no",没有就在末尾加上

  • 在redis-server.exe所在目录打开cmd,运行输入./redis-server.exe回车

java代码使用redis

import com.spring.boot.Application;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;@SpringBootTest(classes = Application.class) //启动类
@RunWith(SpringRunner.class) // junit
public class TestApplication {@AutowiredRedisTemplate redisTemplate;@Testpublic void test(){redisTemplate.opsForValue().set("a","b");redisTemplate.boundValueOps("c").set("d");}@Testpublic void Test2(){Object b = redisTemplate.opsForValue().get("a");System.out.println(b);Object d = redisTemplate.boundValueOps("c").get();System.out.println(d);}
}

5.spring-boot>redis配置使用相关推荐

  1. spring boot + redis 配置

    转:https://blog.csdn.net/jaryle/article/details/81480557 1.引入reids包 spring-boot-starter-redis(springb ...

  2. Spring Boot Redis 入门

    本文,我们基于 Spring Boot 2.X 版本. 1. 概述 在快速入门 Spring Boot 整合 Redis 之前,我们先来做个简单的了解.在 Spring 的生态中,我们使用 Sprin ...

  3. java+cache使用方法_java相关:Spring boot redis cache的key的使用方法

    java相关:Spring boot redis cache的key的使用方法 发布于 2020-8-16| 复制链接 摘记: 在数据库查询中我们往往会使用增加缓存来提高程序的性能,@Cacheabl ...

  4. Spring Boot Redis Cluster 实战干货

    转载自  Spring Boot Redis Cluster 实战干货 添加配置信息 spring.redis:database: 0 # Redis数据库索引(默认为0)#host: 192.168 ...

  5. Spring Boot Redis缓存

    Spring Boot Redis缓存 目录[ 隐藏 ] 1 Spring Boot Redis缓存 1.1 Spring Boot Redis项目设置 1.2 Spring Boot Redis缓存 ...

  6. 太好了 | 这篇写的太好了!Spring Boot + Redis 实现接口幂等性

    Hi ! 我是小小,今天是本周的第四篇,第四篇主要内容是 Spring Boot + Redis 实现接口幂等性 介绍 幂等性的概念是,任意多次执行所产生的影响都与一次执行产生的影响相同,按照这个含义 ...

  7. springboot自动配置原理_今日份学习之Spring Boot自动配置实现原理

    通过前面章节的学习,我们掌握了使用Spring Boot框架进行实际应用开发的方法.在使用Spring Boot 的过程中,我们时常会为一些看似简单,但实际上蕴藏了强大功能的实现而惊呼,下面就让我们来 ...

  8. Spring Boot Redis关闭

    Spring Boot Redis 在开发或者本地没有redis数据库时,控制台会一直报连接超时的日志,可以通过配置取消: spring: data:redis:repositories:enable ...

  9. Spring Boot 自动配置的原理、核心注解以及利用自动配置实现了自定义 Starter 组件

    本章内容 自定义属性快速入门 外化配置 自动配置 自定义创建 Starter 组件 摘录:读书是读完这些文字还要好好用心去想想,写书也一样,做任何事也一样 图 2 第二章目录结构图 第 2 章 Spr ...

  10. Spring Boot 属性配置和使用

    spring Boot 允许通过外部配置让你在不同的环境使用同一应用程序的代码,简单说就是可以通过配置文件来注入属性或者修改默认的配置. Spring Boot 系列 Spring Boot 入门 S ...

最新文章

  1. Vlan 4096的限制原因
  2. Docker----在Docker中部署Asp.net core2.1以及修改发布
  3. 按摩加快肌肉修复有科学依据了,哈佛大学研究成果登Science子刊
  4. android安全问题(二) 程序锁
  5. Lucene.Net如何实现搜索结果分类统计功能
  6. 智能机器人比巴和智伴哪个好_扫地机器人和吸尘器哪个好?
  7. hadoop 传感器数据_hadoop为什么是大数据学习的核心技术?
  8. 面试官系统精讲Java源码及大厂真题 - 32 ReentrantLock 源码解析
  9. 跨交换机间单臂路由的实现方法
  10. LAMP(CentOS 7.2)环境下搭建WordPress
  11. oracle查询锁表进程
  12. 用Axure撰写产品需求文档
  13. 小游戏-在评论留下你的运行结果吧
  14. jadx重新打包_反编译一款APP然后重新打包(Windows环境)
  15. 解决OneNote 无法粘贴图像 的问题
  16. 基于Glodstein枝切法相位解包裹算法
  17. 为自己的位置设定好灯光
  18. DEll EMC R740 raid及安装操作系统
  19. 【离散数学】各类子图与完全图的定义详解
  20. Endnote无法通过在线数据库添加文献, “未找到匹配文献”

热门文章

  1. 【Hive】Beeline CLI介绍
  2. php fatal error: cannot redeclare,Fatal error: Cannot redeclare 常见问题
  3. 用python画月亮和星空_用canvas画一轮明月,夜空与流星
  4. glibc升级导致系统段错误问题解决方案
  5. 2022美赛C题题目及思路--交易策略
  6. 网站分析行业的“前途”和“钱途”
  7. js 读取图片路径并预览图片
  8. 解决“ 故障模块名称: clr.dll ”
  9. 计算机审计体会论文,审计论文格式_计算机审计实验报告_审计论文范文3000字
  10. 服务器数据盘不显示,云服务器不显示数据盘