1
0
mirror of https://gitee.com/coder-xiaomo/flashsale synced 2025-09-13 23:41:39 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

7 Commits

9 changed files with 105 additions and 4 deletions

14
.idea/dataSources.xml generated Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="flashsale/Hibernate" uuid="6a9320fa-cd50-4980-95ca-7f4f4947182e">
<driver-ref>mysql</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<remarks>Hibernate</remarks>
<jdbc-driver>com.mysql.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://127.0.0.1:3306/flashsale?useSSL=false</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

6
.idea/sqldialects.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="PROJECT" dialect="MySQL" />
</component>
</project>

View File

@@ -127,7 +127,7 @@ INSERT INTO `promo_info` VALUES (1, '小米手机抢购活动', '2022-03-05 14:0
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `sequence_info`; DROP TABLE IF EXISTS `sequence_info`;
CREATE TABLE `sequence_info` ( CREATE TABLE `sequence_info` (
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`current_value` int(11) NOT NULL DEFAULT 0, `current_value` int(11) NOT NULL DEFAULT 0,
`step` int(11) NOT NULL DEFAULT 0, `step` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`name`) USING BTREE PRIMARY KEY (`name`) USING BTREE

View File

@@ -84,4 +84,7 @@
@ResponseBody @ResponseBody
``` ```
10. 10. 前端页面
11. 完成

22
pom.xml
View File

@@ -80,6 +80,18 @@
<version>2.9.1</version> <version>2.9.1</version>
</dependency> </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> </dependencies>
<build> <build>
@@ -176,6 +188,16 @@
<target>8</target> <target>8</target>
</configuration> </configuration>
</plugin> </plugin>
<!--
添加SpringBoot打包plugin
解决【flashsale-1.0-SNAPSHOT.jar中没有主清单属性】问题
-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.3</version>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@@ -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 {
}

View File

@@ -0,0 +1,35 @@
package com.cxyxiaomo.flashsale.config;
import org.apache.catalina.connector.Connector;
import org.apache.coyote.ProtocolHandler;
import org.apache.coyote.http11.Http11NioProtocol;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;
/**
* 当Spring容器内没有TomcatEmbeddedServletContainerFactory这个bean时会把当前bean加载进Spring容器中
*/
@Component
public class WebServerConfiguration implements WebServerFactoryCustomizer<ConfigurableWebServerFactory> {
@Override
public void customize(ConfigurableWebServerFactory factory) {
// 使用对应工厂类提供给我们的接口定制化我们的tomcat connector
((TomcatServletWebServerFactory)factory).addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
Http11NioProtocol protocolHandler = (Http11NioProtocol) connector.getProtocolHandler();
// 定制化 KeepAliveTimeout设置30秒内没有请求则服务端自动断开KeepAlive连接
protocolHandler.setKeepAliveTimeout(30000);
// 当客户端发送超过10000个请求则自动断开KeepAlive连接
protocolHandler.setMaxKeepAliveRequests(10000);
}
});
}
}

View File

@@ -5,8 +5,9 @@ import javax.validation.constraints.Max;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable;
public class UserModel { public class UserModel implements Serializable {
private Integer id; private Integer id;
@NotBlank(message = "用户名不能为空") @NotBlank(message = "用户名不能为空")

View File

@@ -10,4 +10,14 @@ spring.datasource.password=111111
# 使用druid数据源 # 使用druid数据源
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 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