springboot-整合redis
2020-03-06 13:59
1106 查看
需要的依赖
application.properties的配置
spring.redis.host=127.0.0.1 spring.redis.database=0 spring.redis.port=6379 spring.redis.password=handhand
Controller
package org.akk.redis; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ValueOperations; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @Autowired StringRedisTemplate stringRedisTemplate; @GetMapping("/set") public void set(){ ValueOperations<String, String> opsForValue = stringRedisTemplate.opsForValue(); opsForValue.set("name","akk"); } @GetMapping("/get") public void get(){ ValueOperations<String, String> opsForValue = stringRedisTemplate.opsForValue(); System.out.println(opsForValue.get("name")); } }
运行后显示密码
登录
http://localhost:8080/set 自动跳转登陆界面
默认用户名user,使用以上密码
运行结果
使用http://localhost:8080/get
将会打印出信息
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- spring boot整合redis
- 记录springboot 整合redis
- spring boot整合redis
- springboot整合redis进行数据操作(一)
- SpringBoot 整合redis
- Spring Boot学习之整合Redis实现缓存
- springboot 整合redis
- spring-boot 整合redis作为数据缓存
- Spring security(四)-spring boot +spring security短信认证+redis整合
- spring boot 整合 redis 超时问题
- Redis配置之Springboot整合实战(一)
- SpringBoot 2.0及以上版本整合redis
- 【转载】Springboot整合 一 集成 redis
- SpringBoot与Redis的整合
- redis学习系列(二)--spring boot整合Redis集群
- SpringBoot整合Redis及Redis工具类撰写
- 记录springboot整合redis
- Spring Boot+Shiro+Redis(redisson)整合时,采用内嵌tomcat启动错误原因分析
- SpringBoot整合mybatis、shiro、redis实现基于数据库的细粒度动态权限管理系统实例
- SpringBoot整合Spring Data Redis