第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 ...
随机推荐
- MVC MVP MVVM 简述
MVC 通过代理或者通知传递数据. MVP 通过P绑定model和view解耦. MVVM 通过V绑定VM(监听VM属性的变化.方法传递(改变自身被监听属性)) VM绑定model设置自身属性.
- 21 ~ express ~ 内容详情展示 和 阅读数处理
1,前台 ,/views/main/index.html ,将文章 id 通过url 传送给后台 {% for content in contents %} <div class="p ...
- Vulkan SDK之 Swapchain
Swapchain是一系列最终会展示给用户的图像的集合. /* * Set up swapchain: * - Get supported uses for all queues * - Try to ...
- oracle数据删除恢复
insert into 表名 select * from 表名 as of timestamp to_Date('2017-07-20 10:00:00', 'yyyy-mm-dd hh24:mi:s ...
- django-替代为自定义的User model
https://docs.djangoproject.com/en/dev/topics/auth/customizing/#substituting-a-custom-user-model Subs ...
- CCCC 正整数A+B
题意: 本题的目标很简单,就是求两个正整数A和B的和,其中A和B都在区间[1,1000].稍微有点麻烦的是,输入并不保证是两个正整数. 输入格式: 输入在一行给出A和B,其间以空格分开.问题是A和B不 ...
- For循环的几个练习
1.括号里面只能放加或减,如果要使等式成立,括号里面应该放什么运算符12()34()56()78()9 = 59 2.蓝球弹起的高度篮球从10米高的地方落下,每次弹起的高度是原来的0.3倍,问弹跳10 ...
- C#调用C++系列一:简单传值
因为去实习的时候有一个小任务是C#想调用C++ opencv实现的一些处理,那我主要的想法就是将C++实现的OpenCV处理封装成dll库供C#调用,这里面还会涉及到一些托管和非托管的概念,我暂时的做 ...
- Vue-router(4)之路由跳转
路由传参 案例:现在需要展示一个电影列表页,点击每一部电影,会跳转到该部电影详情页(跳转时携带type和id) 代码实现(未携带type): index.js import Vue from 'vue ...
- requests.get()///post函数///base64函数
1.requests.get() 一般的用法:r=requests.get(url) 或者是用上session: r=requests.session() r=r.get(url) get()收集的是 ...
