mirror of
https://gitee.com/coder-xiaomo/flashsale
synced 2025-09-13 23:41:39 +08:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
b348a8c060 | |||
cfd3a6f029 | |||
683aa24459 | |||
43d9b53796 | |||
e0912a2429 | |||
c961e9919a | |||
0babe4f15d |
14
.idea/dataSources.xml
generated
Normal file
14
.idea/dataSources.xml
generated
Normal 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
6
.idea/sqldialects.xml
generated
Normal 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>
|
@@ -127,7 +127,7 @@ INSERT INTO `promo_info` VALUES (1, '小米手机抢购活动', '2022-03-05 14:0
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `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,
|
||||
`step` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`name`) USING BTREE
|
||||
|
22
pom.xml
22
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>
|
||||
@@ -176,6 +188,16 @@
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</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>
|
||||
</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 {
|
||||
|
||||
}
|
@@ -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);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -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
|
||||
|
Reference in New Issue
Block a user