springboot 版本

选择 springboot 2.x 的第一个 GA 版本:2.0.7.RELEASE

1
2
3
4
5
6
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.7.RELEASE</version>
<relativePath />
</parent>

添加依赖

1
2
3
4
5
6
7
8
<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>

application.yml

1
2
3
4
5
6
7
8
9
10
11
12
spring:
application:
name: springboot
session:
store-type: redis
redis:
host: 127.0.0.1
port: 6379
password:

server:
port: 8080

Java Config

1
2
3
4
5
@Configuration
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 1800)
public class RedisSessionConfig {

}


Java   SpringBoot      java redis springboot

本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!