一、pom.xml
<!--Redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
二、application.properties
spring.redis.host=192.168.31.22
spring.redis.port=6379
spring.redis.password=123456
三、业务层
springboot会自动注入一个redisTemplate,直接应用即可
@Autowired
private RedisTemplate<Object,Object> redisTemplate;
然后在业务逻辑中正常使用redisTemplate即可