当前位置:   article > 正文

springboot整合redis_5.springboot整合redis redis下载安装,解压启动redis-server.ex

5.springboot整合redis redis下载安装,解压启动redis-server.exe即可 使

springboot整合redis

参考哔哩哔哩上的视频截取的页面

测试一下

1.导入依赖

<!--操作redis-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-redis</artifactId>
		</dependency>
  • 1
  • 2
  • 3
  • 4
  • 5

2.配置链接

#配置redis
spring.redis.host=127.0.0.1
spring.redis.port=6379
  • 1
  • 2
  • 3

3.测试

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

@SpringBootTest
class Redis02SpringbootApplicationTests {

	@Autowired
	private RedisTemplate redisTemplate;

	@Test
	void contextLoads() {
		redisTemplate.opsForValue ().set ("mykey","xingfuhao");
		System.out.println (redisTemplate.opsForValue ().get ("mykey"));
}}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/791190
推荐阅读
相关标签
  

闽ICP备14008679号