【SpringBoot】SpringBoot项目中实现数据缓存

步骤01 引入Redis依赖包

<dependency>

<groupId>org.springframework.boot

</groupId>

<artifactId>spring-boot-starter-data-redis

</artifactId>

</dependency>

步骤02 修改配置文件

在application.properties配置文件增加有关Redis的配置:

步骤03 验证测试

@SpringBootTest

public class TestRedisTemplate{

@Autowired

private RedisTemplate redisTemplate;

@Test

public void testString(){

//调用set()方法创建缓存

redisTemplate.opsForVaule().set("hello:redis","hello spring boot");

System.out.println("hello,redis:"+redisTemplate.opsForValue().get("hello:redis"));

}

}

相关推荐
学长毕设18 小时前
基于SpringBoot的青少年编程学习平台系统-附源码
spring boot·学习·青少年编程
学长毕设1 天前
基于SpringBoot的建筑材料管理系统-附源码
java·spring boot·后端
星光开发者1 天前
基于springboot智慧草场牛羊管理系统-计算机毕设【课程设计】50360
vue.js·spring boot·后端·mysql·php·课程设计·express
weixin_BYSJ19871 天前
电竞先锋网站---附源码02032
java·vue.js·spring boot·python·django·tomcat·php
她的男孩1 天前
超时配置了自动驳回,任务状态却全变「已取消」:Forge Admin 流程超时终态与 Flowable ENTITY_DELETED
spring boot·低代码·工作流引擎
二宝哥1 天前
02.springboot项目对接国内模型实现对话聊天
数据库·人工智能·spring boot
学长毕设1 天前
基于springboot的农资管理系统-附源码
java·spring boot·后端
Magicdata大数据1 天前
AI辅助教学:调用大模型从教材中生成习题,方便学员练习
java·spring boot·大模型·知识图谱·neo4j·ai辅助教学
不识君1 天前
esl-client 2.0.0 发布:Java 项目接入 FreeSWITCH,从引入到使用
spring boot·后端·开源
二宝哥1 天前
03.Spring AI Embedding 实战:从向量化原理到项目落地
人工智能·spring boot·向量·spring ai