在配置文件中加入redis配置
这里要注意如果redis设置了密码要加上
spring.redis.password=*****
*****代表你redis设置的密码
如果链接不上
有可能是因为你的redis没开启
开启redis
输入命令查看开启redis没有
ps -ef | grep redis
如果还链接不上redis 可能是防火墙原因
输入命令关闭防火墙
systemctl stop firewalld
如果仍然链接不上
可能是redis端口未开放
去宝塔页面开放,这里就不做演示了
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
spring.redis.host=8.130.169.21
spring.redis.port=6379
spring.redis.database= 0
spring.redis.timeout=1800000
spring.redis.password=*****
spring.redis.lettuce.pool.max-active=20
spring.redis.lettuce.pool.max-wait=-1
#最大阻塞等待时间(负数表示没限制)
spring.redis.lettuce.pool.max-idle=5
spring.redis.lettuce.pool.min-idle=0
在config包中中加入redis的配置
package com.atguigu.yygh.common.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.inter