springboot学习之三(整合redis)

 

springboot整合redis

1.依赖

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

2.配置

# Redis 配置
spring.redis.host=localhost
spring.redis.port=6379
...其他设置

 

 

 

 

    @Autowired(required = false)
    RedisTemplate redisTemplate;

    @RequestMapping("/redis1")
    public String redis1(){

        redisTemplate.boundValueOps("name").set("fps2tao");
        System.out.println(redisTemplate.boundValueOps("name").get());
        return "redis1";
    }

 

 

 

 

https://www.cnblogs.com/fps2tao/p/13824958.html

 

posted @ 2023-04-13 16:47  与f  阅读(29)  评论(0编辑  收藏  举报