目录
一、pom.xml依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--如果使用lettuce连接池的话就不用导入jedis-->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
二、application.properties配置
## redis setting
spring.redis.host=127.0.0.1
spring.redis.password=123456
spring.redis.port=6379
## redis jedis pool setting
spring.redis.jedis.pool.max-active=20
spring.redis.jedis.pool.max-idle=10
spring.redis.jedis.pool.max-wait=-1
spring.redis.jedis.pool.min-idle=5
## redis lettuce pool setting
spring.redis.lettuce.pool.max-active=20
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=5
三、java配置类
1.配置Redis连接池JedisPool
2.配置RedisTemplate存值取值序列化
package com.leadpms.qianlistandard.web.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.