diff --git a/pom.xml b/pom.xml index 75752a3..1d2b605 100644 --- a/pom.xml +++ b/pom.xml @@ -80,6 +80,18 @@ 2.9.1 + + + org.springframework.boot + spring-boot-starter-data-redis + + + + + org.springframework.session + spring-session-data-redis + 2.0.5.RELEASE + diff --git a/src/main/java/com/cxyxiaomo/flashsale/config/RedisConfig.java b/src/main/java/com/cxyxiaomo/flashsale/config/RedisConfig.java new file mode 100644 index 0000000..a9e2212 --- /dev/null +++ b/src/main/java/com/cxyxiaomo/flashsale/config/RedisConfig.java @@ -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 { + +} diff --git a/src/main/java/com/cxyxiaomo/flashsale/service/model/UserModel.java b/src/main/java/com/cxyxiaomo/flashsale/service/model/UserModel.java index 9f14bfd..82f9cf9 100644 --- a/src/main/java/com/cxyxiaomo/flashsale/service/model/UserModel.java +++ b/src/main/java/com/cxyxiaomo/flashsale/service/model/UserModel.java @@ -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 = "用户名不能为空") diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0fa7365..6c50aa0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -10,4 +10,14 @@ spring.datasource.password=111111 # 使用druid数据源 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource -spring.datasource.driverClassName=com.mysql.jdbc.Driver \ No newline at end of file +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