pom.xml

<dependencies>
<!-- ... -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
</dependencies>
spring.session.store-type=redis # Session 存储类型为redis
spring.session.redis.namespace=spring:session # redis存储的key前缀

redis设置同spring-data-redis设置

spring.redis.host=localhost # Redis server host.
spring.redis.password= # Login password of the redis server.
spring.redis.port=6379 # Redis server port.

参考:​​https://docs.spring.io/spring-session/docs/current/reference/html5/guides/boot-redis.html​