崛起于Springboot2.X + 单机Redis(14)
《SpringBoot2.X心法总纲》 简介:单机redis+springboot,并不是jedis单机操作redis,jedis是需要另外的集成,下一篇博客会讲到。 1、添加pom依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> 2、添加配置文件 spring.redis.database=0 spring.redis.host=localhost spring.redis.port=6379 spring.redis.password= spring.redis.timeout=10000ms 2.0之后需要加ms参数才可以,不然报错,所以以后找2.0博客,标题说是springboot 2.0,但是内容依然是spring.redis.timeout=10000后面没有加ms的都是1.X版本,博客都不是很严格。 3、连接成功 @RestController public class TestController { @Autowired StringRedisTemplate stringRedisTemplate; @RequestMapping(value = "