SpringBoot 秒杀项目

[TOC]

项目介绍、开发环境、环境搭建

课程技术点

第一章 项目框架搭建

SpringBoot 环境搭建

集成 Thymeleaf,Result 结果封装

Result 结果封装前后对比
public Result<String> hello() {
	 		return Result.success("hello,imooc");
	       // return new Result(0, "success", "hello,imooc");
	       // 每次都要 new 对象,浪费
	       // 看起来也干净利落
	    }
复制代码
集成 thymeleaf

return hello,SpringBoot 会自动寻找视图解析器,比如我配置的 Thymeleaf,然后根据配置文件

#在构建 URL 时添加的前缀
spring.thymeleaf.prefix=classpath:/templates/
#构建 URL 时添加的后缀
spring.thymeleaf.suffix=.html
复制代码

组装成转发路径 hello.html

@RequestMapping("/thymeleaf")
	    public String thymeleaf(Model model) {
	 		model.addAttribute("name", "Xiehang");
	 		return "hello";
	    }
复制代码

thymeleaf 配置文件

#不缓存页面
spring.thymeleaf.cache=false 
#内容为 text/html
spring.thymeleaf.content-type=text/html
#启用 MVC thymeleaf 视图解析
spring.thymeleaf.enabled=true
#模板编码
spring.thymeleaf.encoding=UTF-8
#要应用于模板的模板模式
spring.thymeleaf.mode=HTML5
#在构建 URL 时添加的前缀
spring.thymeleaf.prefix=classpath:/templates/
#构建 URL 时添加的后缀
spring.thymeleaf.suffix=.html
复制代码

集成 Mybatis + Druid

集成 Mybatis

Mybatis 配置

# mybatis
mybatis.type-aliases-package=com.xiehang.miaosha.domain
mybatis.configuration.map-underscore-to-camel-case=true
mybatis.configuration.default-fetch-size=100
mybatis.configuration.default-statement-timeout=3000
mybatis.mapperLocations = classpath:com/xiehang/miaosha/dao/*.xml
复制代码

这里不采用 xml 的方式配置 SQL 语句,而是在 dao 接口上写注解 @select、@update...

@Mapper
public interface UserDao {

    @Select("select * from user where id = #{id}")
    public User getById(@Param("id") int id);
}
复制代码

集成 Jedis + Redis 安装 + 通用缓存 Key 封装

第二章 实现登录功能

第三章 实现秒杀功能

第四章 Jmeter 压力测试

第五章 页面优化技术

第六章 接口优化

第七章 安全优化

转载于:https://juejin.im/post/5cbd6c74e51d456e4514f56f

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值