- 这个已经引入了,因为创建的时候勾选了
-
-
org.springframework.boot -
spring-boot-starter-data-redis -
-
-
org.apache.commons -
commons-pool2 -
记得把文件后缀改为yml
- spring:
- redis:
- host: 127.0.0.1
- port: 6380
- password: 123321
- lettuce:
- pool:
- max-active: 8
- max-idle: 8
- min-idle: 0
- max-wait: 1000ms
@Autowired private RedisTemplate redisTemplate;
- @SpringBootTest
- class RedisDemoApplicationTests {
-
- @Autowired
- private RedisTemplate redisTemplate;
-
- @Test
- void contextLoads() {
- redisTemplate.opsForValue().set("name","lisi");
-
- Object name =redisTemplate.opsForValue().get("name");
- System.out.println("name = " + name);
-
-
-
- }
-
- }
通过RDM可以看到name:"胡个"已经被存储