mirror of
https://gitee.com/coder-xiaomo/flashsale
synced 2025-01-10 11:48:14 +08:00
Redis 分布式会话(基于session)
This commit is contained in:
parent
cfd3a6f029
commit
b348a8c060
12
pom.xml
12
pom.xml
@ -80,6 +80,18 @@
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--引入SpringBoot对Redis的依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--SpringBoot将Session存储在Redis中-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
<version>2.0.5.RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.cxyxiaomo.flashsale.config;
|
||||
|
||||
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 3600) // 会话1hour过期
|
||||
public class RedisConfig {
|
||||
|
||||
}
|
@ -5,8 +5,9 @@ import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserModel {
|
||||
public class UserModel implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
@NotBlank(message = "用户名不能为空")
|
||||
|
@ -10,4 +10,14 @@ spring.datasource.password=111111
|
||||
|
||||
# 使用druid数据源
|
||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||
spring.datasource.driverClassName=com.mysql.jdbc.Driver
|
||||
spring.datasource.driverClassName=com.mysql.jdbc.Driver
|
||||
|
||||
# 配置SpringBoot对Redis的依赖
|
||||
spring.redis.host=127.0.0.1
|
||||
spring.redis.port=6379
|
||||
spring.redis.database=10
|
||||
#spring.redis.password=
|
||||
|
||||
# 设置jedis连接池
|
||||
spring.redis.jedis.pool.max-active=50
|
||||
spring.redis.jedis.pool.max-idle=20
|
||||
|
Loading…
Reference in New Issue
Block a user