step1:
添加pom依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
step2:
配置yml
spring:
redis:
host:120.0.0.1
port:6379 //默认端口
//配置了用户密码的需要配置
step3:
//使用RedisTempLate
redisTemplate.opsForValue().set();
redisTemplate.opsForValue().get();
redis遇见连接不上的问题:
redis.windows.conf or redis.windows-service.conf
1,bind127.0.0.1 需要注释 允许外部连接
2,protected-mode 保护关闭