一、在pom文件中添加依赖
<!-- 集成redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
二、在application.yml文件中配置redis
spring:
redis:
host: 127.0.0.1 #redis服务器IP地址
port: 6379 #端口号
jedis:
pool:
max-active: 8 #最大连接数
max-idle: 8 #最大空闲数
min-idle: 0 #最小空闲数
max-wait: 30000 #最大等待时间 ms(毫秒)
timeout: 50000 #连接超时时间 ms(毫秒)
database: 0 #连接的数据库
三、创建RedisConfig文件
package com.xf.base.config;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.