一、系统方案

二、项目搭建

1. 引入依赖

包括thymeleaf组件、web组件、test组件、MySQL驱动、Mybatis-plus、lombok插件

    <dependencies><!--thymeleaf--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency><!--web--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!--mybatis-plus--><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.1</version></dependency><!--mysql--><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope></dependency><!--lombok--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><!--test--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>2.3.4.RELEASE</version><configuration><excludes><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes></configuration></plugin></plugins></build>

(其中spring-boot-maven-plugin报红,暂时无影响)

2. 修改配置文件

spring:# thymeleaf 配置thymeleaf:cache:false# 数据源配置datasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/seckill?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghaiusername: rootpassword: roothikari:# 连接池名pool-name: DateHikariCP# 最小空闲连接数minimum-idle: 5# 空闲连接存活最大时间,默认600000 (10分钟)idle-timeout: 1800000# 最大连接数,默认10maximum-pool-size: 10# 从连接池返回的连接自动提交auto-commit: true# 连接最大存活时间,0表示永久存活,默认30分钟max-lifetime: 1800000# 连接超时时间,默认30sconnection-timeout: 30000# 测试连接是否可用的查询语句connection-test-query: SELECT 1mybatis-plus:# 配置 Mapper.xmlmapper-locations: classpath*:/mapper/*Mapper.xml# 配置 MyBatis数据返回类型别名(默认别名是类名)type-aliases-package: com.example.seckill.pojo# MyBatis SQL打印(方法接口所在的包,不是 Mapper.xml 所在的包)
logging:level:com.example.seckill.mapper: debug

3. 测试项目搭建


用控制层和简单html进行测试

@Controller
@RequestMapping("/demo")
public class DemoController {/*** 测试页面跳转* @author 47roro* @date 2022/4/3**/@RequestMapping("/hello")public String hello(Model model){model.addAttribute("name", "example");return "hello";}
}
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>测试</title>
</head>
<body>
<p th:text="'hello,' + ${name}"></p>
</body>
</html>

url 输入localhost:8080/demo/hello请求到html页面,输出结果

三、数据库建立

1. 建立数据库

use seckill;
create table t_user(
`id` bigint(20) not null comment '用户ID,手机号码',
`nickname` varchar(255) not null,
`password` varchar(32) default null comment 'MD5(MD5(pass明文+固定salt) + salt)',
`salt` varchar(10) default null,
`head` varchar(128) default null comment '头像',
`register_date` datetime default null,
`last_login_date` datetime default null,
`login_count` int(11) default 0,
primary key(`id`)
)

2. 2次MD5加密

第一次前端传给后端的时候进行一次MD5加密,防止用户密码在网络中明文传输;第二次后端传给数据库的时候进行二次MD5加密,防止数据库丢失后,破解者通过salt进行解密破解密码。

3. 引入MD5依赖

<!-- md5 依赖 -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>

4. 准备utils工具类

public class MD5Util {public static String md5(String src){return DigestUtils.md5Hex(src);}// 和前端的salt保持一直private static final String salt = "1a2b3c4d";public static String inputPassToFromPass(String inputPass){String str = "" + salt.charAt(0) + salt.charAt(2) + inputPass + salt.charAt(5) + salt.charAt(4);return md5(str);}public static String frompassToDBPass(String fromPass, String salt){String str = "" + salt.charAt(0) + salt.charAt(2) + fromPass + salt.charAt(5) + salt.charAt(4);return md5(str);}public static String inputPassToDBPass(String inputPass, String salt){String fromPass = inputPassToFromPass(inputPass);String dbPass = frompassToDBPass(fromPass, salt);return dbPass;}
}

测试结果:

第一次加密密码:
ce21b747de5af71ab5c2e20ff0a60eea
第二次加密密码:
0687f9701bca74827fcefcd7e743d179
存入数据库的密码:
0687f9701bca74827fcefcd7e743d179

四、redis下载及安装

参考博客:centos安装redis及相关配置和命令

视频参考:

优极限-秒杀项目

【学习笔记】seckill-秒杀项目--(1)搭建项目相关推荐

  1. 谷粒商城学习笔记(2)-- 环境搭建项目结构创建

    一.环境 虚拟机ip192.168.174.128 本地ip192.168.31.14 本地和虚拟机要互相ping通 二.Docker 虚拟化容器技术.Docker基于镜像,可以秒级启动各种容器.每一 ...

  2. Redis学习笔记②实战篇_黑马点评项目

    若文章内容或图片失效,请留言反馈.部分素材来自网络,若不小心影响到您的利益,请联系博主删除. 资料链接:https://pan.baidu.com/s/1189u6u4icQYHg_9_7ovWmA( ...

  3. Vue学习笔记:使用CLI构建Vue项目

    Vue学习笔记:使用CLI构建Vue项目 一.安装Vue CLI 要用到集成在node.js里的npm来安装Vue CLI. 1.下载并安装node.js 2.配置node.js的环境变量 3.启动命 ...

  4. 【AngularJs学习笔记五】AngularJS从构建项目开始

    为什么80%的码农都做不了架构师?>>>    #0 系列目录# AngularJs学习笔记 [AngularJs学习笔记一]Bower解决js的依赖管理 [AngularJs学习笔 ...

  5. 华芯微特SWM181学习笔记--GPIO应用与环境搭建

    华芯微特SWM181 系列 32 位 MCU(以下简称 SWM181)内嵌 ARM® CortexTM-M0 内核, SWM181 支持片上包含精度为 1%以内的 24MHz.48MHz 时钟,并提供 ...

  6. 迪文屏幕T5L平台学习笔记一:开发环境搭建注意事项

    前面一直用T5UID3平台的屏幕开发,但是吐槽下<DWIN C Compiler 1>编译器bug太多,项目能不能做好,全靠运气:售后说T5L平台支持keil开发,我感觉挺好,于是从新学习 ...

  7. nginx学习笔记-01nginx入门,环境搭建,常见命令

    nginx学习笔记-01nginx入门,环境搭建,常见命令 文章目录 nginx学习笔记-01nginx入门,环境搭建,常见命令 1.nginx的基本概念 2.nginx的安装,常用命令和配置文件 3 ...

  8. Hibernate框架--学习笔记(上):hibernate项目的搭建和常用接口方法、对象的使用

    一.什么是Hibernate框架: 1.Hibernate是一个操作数据库的框架,实现了对JDBC的封装: 2.Hibernate是一个ORM(对象关系映射)框架,我们在写程序时 ,用的是面向对象的方 ...

  9. 微前端MicroApp的学习(一):简单搭建项目

    前言 最近公司框架升级,微前端选择了京东的MicroApp ,因为后续会参与开发.提前来学习一波. 推荐文章 极致简洁的微前端框架-京东MicroApp开源了 初探 MicroApp,一个极致简洁的微 ...

  10. python编程计算器_Python学习笔记:用Python开发一个计算器项目

    最近抽空看了下python的学习文档,发现开发工具以及资料支持对开发者相当的友好,相比之下,以前用TCL&Tk做的项目主要缺点有两个:1,开发难度大,调试手段只有靠print一种,而且语法错误 ...

最新文章

  1. python pytest测试框架介绍四----pytest-html插件html带错误截图及失败重测机制
  2. 个人项目框架搭建 -- 缓存接口与实现
  3. 单位员工通讯录管理系统(线性表的应用)
  4. Windows删除指定时间之前指定后缀名的文件
  5. 安卓入门系列-02创建一个项目
  6. 利用js实现 禁用浏览器后退| 去除上一个历史记录链接
  7. 一文详解,RocketMQ事务消息
  8. Python版的百钱买百鸡问题
  9. Spring Security UserDetail
  10. swagger ui 值类型形参加文字注释
  11. mysql5.0版本特性_mysql各版本的新特性整理
  12. C++基础::运算符重载
  13. 是时候拥有一个你自己的命令行工具了
  14. AirTest进行自动化测试
  15. flink集成springboot案例_集成-Apache Flink+Spring Boot
  16. Git报错:Git failed with a fatal error. Git failed with a fatal error. Need to specify how to reconcile
  17. bcd 初始化库系统卷失败_中级|软考题库每日一练|2.24
  18. 数字化技术成为门店的重要推手?
  19. VC版DoEvents/处理事件
  20. 四代增强 (BTE实例详解)

热门文章

  1. 苹果鼠标怎么充电_macbook pro搭配什么鼠标好?
  2. 基于python-实现仿天眼查-企查查-完整源码
  3. 英国正在大举进军AI,看懂其三大投资走向
  4. 货币金融学(米什金)笔记:金融体系、货币相关
  5. 伯努利分布、二项分布和多项分布
  6. 国际市场营销知识框架图_留学热门丨伦敦里士满大学市场营销本科专业
  7. 小程序_古诗词背诵小程序
  8. oracle 按汉字拼音顺序排序
  9. Chrome浏览器快捷键大全
  10. 页面加载时,下方内容在上方图片位置闪现