第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第十二天】(系统架构讲解、nginx)
https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040
第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第七天】(redis缓存)
第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第八天】(solr服务器搭建、搜索功能实现)
第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第九天】(商品详情页面实现)
第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第十天】(单点登录系统实现)
第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第十一天】(购物车+订单)
第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第十二天】(系统架构讲解、nginx)
1 昨天内容复习
1、在单点登录系统中增加注册和登录的功能
2、登录系统功能判断是否有回调url。
3、Taotao-Protal中添加拦截器。
4、购物车的实现
a) 添加商品商品列表写入cookie中。
b) 展示购物车列表,从cookie中取商品列表
c) 修改购物车的商品数量
d) 删除购物车商品。
2 今天内容
1、订单系统的实现(独立的系统)
2、Taotao-portal调用订单系统服务创建订单。
3 订单系统的实现
3.1 系统架构

3.2 订单系统包含的功能
1、下单功能
2、查看订单列表
3、根据订单号查看订单详情。
下单功能一定要使用关系型数据库表,保证数据的一致性。
3.6.3 Dao层
要对三个表进行操作。都是插入操作。可以使用逆向工程生成的代码。
3.6.4 Service层
功能:接收三个参数,
1、对应订单表的pojo。
2、订单明细表对应的商品列表。每个元素是订单明细表对应的pojo
3、物流表对应的pojo
3.6.5 Controller层
接收一个json格式的字符串作为参数。需要使用@RequestBody注解。需要使用一个pojo接收参数。创建一个对应json格式的pojo。
4.3.2 Controller层
接收页面提交的表单的内容,调用Service创建订单。返回成功页面。
@Controller
@RequestMapping("/order")
public class OrderController { @Autowired
private CartService cartService; @Autowired
private OrderService orderService; @RequestMapping("/order-cart")
public String showOrderCart(HttpServletRequest request,HttpServletResponse response,Model model) {
//取购物车商品列表
List<CartItem> list = cartService.getCartItemList(request, response);
model.addAttribute("cartList", list); return "order-cart";
} //接收页面提交的表单的内容,调用Service创建订单。返回成功页面。
@RequestMapping("/create")
public String createOrder(Order order, Model model) {
String orderId = orderService.createOrder(order);
model.addAttribute("orderId", orderId);
model.addAttribute("payment", order.getPayment());
model.addAttribute("date", new DateTime().plusDays(3).toString("yyyy-MM-dd"));
return "success";
} }
<!-- 时间操作组件 -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
</dependency>
5 框架梳理


6 网络拓扑图


7 Nginx
7.1 什么是nginx
Nginx是一款高性能的http 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器。官方测试nginx能够支支撑5万并发链接,并且cpu、内存等资源消耗却非常低,运行非常稳定。开源、免费。
7.2 Nginx的应用场景
1、http服务器。Nginx是一个http服务可以独立提供http服务。可以做网页静态服务器。
2、虚拟主机。可以实现在一台服务器虚拟出多个网站。例如个人网站使用的虚拟主机。
3、反向代理,负载均衡。当网站的访问量达到一定程度后,单台服务器不能满足用户的请求时,需要用多台服务器集群可以使用nginx做反向代理。并且多台服务器可以平均分担负载,不会因为某台服务器负载高宕机而某台服务器闲置的情况。
5 负载均衡
5.1 什么是负载均衡
负载均衡 建立在现有网络结构之上,它提供了一种廉价有效透明的方法扩展网络设备和服务器的带宽、增加吞吐量、加强网络数据处理能力、提高网络的灵活性和可用性。
负载均衡,英文名称为Load Balance,其意思就是分摊到多个操作单元上进行执行,例如Web服务器、FTP服务器、企业关键应用服务器和其它关键任务服务器等,从而共同完成工作任务。
5.2 需求
nginx作为负载均衡服务器,用户请求先到达nginx,再由nginx根据负载配置将请求转发至 tomcat服务器。
nginx负载均衡服务器:192.168.25.141
tomcat1服务器:192.168.25.141:8080
tomcat2服务器:192.168.25.141:8081
5.3 配置nginx的负载均衡

节点说明:
在http节点里添加: #定义负载均衡设备的 Ip及设备状态
upstream myServer { server 127.0.0.1: down;
server 127.0.0.1: weight=;
server 127.0.0.1:;
server 127.0.0.1: backup;
} 在需要使用负载的Server节点下添加 proxy_pass http://myServer; upstream 每个设备的状态: down 表示单前的server暂时不参与负载
weight 默认为1.weight越大,负载的权重就越大。
max_fails :允许请求失败的次数默认为1.当超过最大次数时,返回proxy_next_upstream 模块定义的错误
fail_timeout:max_fails 允许的最多次的失败后,暂停的时间。
backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。
================================================
参考资料:
end
第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第十二天】(系统架构讲解、nginx)的更多相关文章
- 第04项目:淘淘商城(SpringMVC+Spring+Mybatis) 的学习实践总结【第二天】
淘淘商城(SpringMVC+Spring+Mybatis) 是传智播客在2015年9月份录制的,几年过去了.由于视频里课上老师敲的代码和项目笔记有些细节上存在出入,只有根据日志报错信息作出适当的调 ...
- 第04项目:淘淘商城(SpringMVC+Spring+Mybatis) 的学习实践总结【第一天】
本人做过一年的MATLAB编程和简单维护过VB和C++的项目.是跟着网上获得的黑马的Java双元视频课来自学入门Java知识和常用框架的使用. 淘淘商城(SpringMVC+Spring+Mybati ...
- 第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第十一天】(购物车+订单)
https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...
- 第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第十天】(单点登录系统实现)
https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...
- 第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第九天】(商品详情页面实现)
https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...
- 第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第八天】(solr服务器搭建、搜索功能实现)
https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...
- 第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第七天】(redis缓存)
https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...
- 第04项目:淘淘商城(SpringMVC+Spring+Mybatis) 的学习实践总结【第六天】
https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...
- 第04项目:淘淘商城(SpringMVC+Spring+Mybatis) 的学习实践总结【第五天】
https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...
随机推荐
- jquery 获取同级元素
$(".userinfo-three:eq(0)").css({ "width": winWidth * 300 / 1080, ...
- ROS常用命令或经常碰到的问题
本篇博客会随时更新. 一.常用命令 1.添加环境变量 gedit ~/.bashrc 2.ubuntu系统监视器 gnome-system-monitor 二.问题 1.sudo apt-get up ...
- bzoj 3876: [Ahoi2014]支线剧情
就是加一个1的下界就好了. #include<bits/stdc++.h> #define N 100005 #define LL long long #define inf 0x3f3f ...
- 详解contextConfigLocation|Spring启动过程详解(转)
原文链接:https://blog.csdn.net/qw222pzx/article/details/78191670 spring的应用初始化流程一直没有搞明白,刚刚又碰到了相关的问题.决定得好好 ...
- 十、CI框架之通过参数的办法输出URI路径
一.代码如下,index函数有2个参数 二.效果如下: 不忘初心,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:382477247)哦,谢谢.
- Maven - Repository(存储库)
版权所有,未经授权,禁止转载 章节 Maven – 简介 Maven – 工作原理 Maven – Repository(存储库) Maven – pom.xml 文件 Maven – 依赖管理 Ma ...
- .NET Core开发实战(第11课:文件配置提供程序)--学习笔记
11 | 文件配置提供程序:自由选择配置的格式 文件配置提供程序 Microsoft.Extensions.Configuration.Ini Microsoft.Extensions.Configu ...
- 18 12 07 MySQL 与python 的交互
---恢复内容开始--- python 中 关于SQL语句的查询 from pymysql import * # 由于只能用了一个MySQL 的包所以全部引进 def main(): # 创建Conn ...
- C++11多线程访问时候的数据保护实例
#include<iostream> #include<thread> #include<string> #include<vector> #inclu ...
- JavaWeb乱码问题及统一全站编码(通过Filter实现)
1. public class CharacterFilter implements Filter { private String characterEncoding = null; FilterC ...
