SpringBoot使用redisTemplate操作Redis

1.pom文件引入spring-boot-starter-data-redis

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>

2.yml文件配置

spring:
  redis:
    host: xxx
    port: xxx
    password: 
    lettuce:
      pool:
        max-active: 5
        max-idle: 5

3.在对应的impl文件中添加注解就可以使用。

@Autowired
    private StringRedisTemplate redisTemplate;

  

posted @ 2022-10-13 09:44  羽毛球打的贼好  阅读(82)  评论(0)    收藏  举报