1.pom依赖
org.springframework.boot
spring-boot-starter-data-redis
redis.clients
jedis
io.lettuce
lettuce-core
redis.clients
jedis
org.springframework.session
spring-session-data-redis
2.1.12.RELEASE
2.properties配置
#redis
spring.redis.database=0
spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=
spring.redis.timeout=30s
spring.redis.lettuce.pool.max-active=8
spring.redis.lettuce.pool.max-idle=8
spring.redis.lettuce.pool.max-wait=-1s
spring.redis.lettuce.pool.min-idle=0
spring.redis.lettuce.shutdown-timeout=100ms
#session 共享
spring.session.store-type=redis
3.启动类加注解
@EnableRedisHttpSession//session共享
public class SpringbootApplication{
}
4.如果报错存入sess的User类无法序列化的话
User类加一个
implements Serializable