主讲老师:入云龙
- 课程计划
一共14天课程
- 第一天:电商行业的背景。淘淘商城的介绍。搭建项目工程。Svn的使用。
- 第二天:框架的整合。后台管理商品列表的实现。分页插件。
- 第三天:后台管理。商品添加。商品类目的选择、图片上传、富文本编辑器的使用。
- 第四天:商品规格的实现。
- 第五天:商城前台系统的搭建。首页商品分类的展示。Jsonp。
- 第六天:cms系统的实现。前台大广告位的展示。
- 第七天:cms系统添加缓存。Redis。缓存同步。
- 第八天:搜索功能的实现。使用solr实现搜索。
- 第九天:商品详情页面的展示。
- 第十天:单点登录系统。Session共享。
- 第十一天:购物车订单系统的实现。
- 第十二天:nginx。反向代理工具。
- 第十三天:redis集群的搭建、solr集群的搭建。系统的部署。
- 项目总结。
今天的内容:
- 电商行业的背景。
- 淘淘商城的介绍。
- 工程项目的搭建。
- Svn的使用。
- 电商行业介绍
- 电商行业发展
近年来,中国的电子商务快速发展,交易额连创新高,电子商务在各领域的应用不断拓展和深化、相关服务业蓬勃发展、支撑体系不断健全完善、创新的动力和能力 不断增强。电子商务正在与实体经济深度融合,进入规模性发展阶段,对经济社会生活的影响不断增大,正成为我国经济发展的新引擎。
中国电子商务研究中心数据显示,截止到2012年底,中国电子商务市场交易规模达7.85万亿人民币,同比增长30.83%。其中,B2B电子商务交易额 达6.25万亿,同比增长27%。而2011年全年,中国电子商务市场交易额达6万亿人民币,同比增长33%,占GDP比重上升到13%;2012年,电 子商务占GDP的比重已经高达15%。预计2013年我国电子商务规模将突破十万亿大关。
图1.2009-2014年中国电子商务市场交易规模(万亿元)
-
- 11.11
-
- 电商行业技术特点
- 技术新
- 技术范围广
- 分布式
- 高并发、集群、负载均衡、高可用
- 海量数据
- 业务复杂
- 系统安全
- 淘淘商城
- 淘淘商城简介
- 电商行业的模式:
- 淘淘商城简介
B2B:企业到企业,商家到商家。代表:阿里巴巴、慧聪网。
B2C:商家到客户。代表:京东、淘宝商城(B2B2C)。
C2C:客户到客户。淘宝集市。
O2O:线上到线下。
电子商务的这几种模式要清楚!
-
-
- 淘淘商城的模式
-
淘淘网上商城是一个综合性的B2C平台,类似京东商城、天猫商城。会员可以在商城浏览商品、下订单,以及参加各种活动。
管理员、运营可以在平台后台管理系统中管理商品、订单、会员等。
客服可以在后台管理系统中处理用户的询问以及投诉。
-
- 功能模块
-
-
- 功能描述
-
后台管理系统:管理商品、订单、类目、商品规格属性、用户管理以及内容发布等功能。
前台系统:用户可以在前台系统中进行注册、登录、浏览商品、首页、下单等操作。
会员系统:用户可以在该系统中查询已下的订单、收藏的商品、我的优惠券、团购等信息。
订单系统:提供下单、查询订单、修改订单状态、定时处理订单。
搜索系统:提供商品的搜索功能。
单点登录系统:为多个系统之间提供用户登录凭证以及查询登录用户的信息。
-
- 技术架构
- 传统架构
- 技术架构
思考:有什么问题?
- 模块之间耦合度太高,其中一个升级其他都得升级
- 开发困难,各个团队开发最后都要整合一起
- 系统的扩展性差
- 不能灵活的进行分布式部署。
解决方法:
优点:
把模块拆分成独立的工程,单点运行。如果某一个点压力大可以对这一个点单独增加配置。其他的点不受影响。
缺点:
系统之间交互需要额外的工作量来进行接口的开发。
其实这个时候就有了服务的概念,一个大系统有很多很多的功能,以前我们是采用集群的方式来进行扩展,这样做有点浪费资源,比如我们要提高前端商品的并发量,由于我们的系统是All in one 的方式,不能非常精确的去提高某个某块的功能,造成资源的浪费
把系统拆分成多个工程,要完成系统的工程需要多个工程协作完成。这种形式叫做分布式。
-
-
- 分布式的架构
-
分布式架构:
把系统按照模块拆分成多个子系统。
优点:
- 把模块拆分,使用接口通信,降低模块之间的耦合度。
- 把项目拆分成若干个子项目,不同的团队负责不同的子项目。
- 增加功能时只需要再增加一个子项目,调用其他系统的接口就可以。
- 可以灵活的进行分布式部署。
缺点:
系统之间交互需要使用远程通信,接口开发增加工作量。
-
-
- 技术选型(主要技术)
-
- Spring、SpringMVC、Mybatis
- JSP、JSTL、jQuery、jQuery plugin、EasyUI、KindEditor(富文本编辑器)、CSS+DIV
- Redis(缓存服务器)
- Solr(搜索)
- httpclient(调用系统服务)
- Mysql
- Nginx(web服务器)
-
- 开发工具和环境
-
Eclipse 4.5.0(Mars),自带maven插件,需要手工安装svn插件。
Maven 3.3.3(开发工具自带)
Tomcat 7.0.53(Maven Tomcat Plugin)
JDK 1.7
Mysql 5.6
Nginx 1.8.0
Redis 3.0.0
Win7 操作系统
SVN(版本管理)
-
- 人员配置
产品经理:3人,确定需求以及给出产品原型图。
项目经理:1人,项目管理。
前端团队:5人,根据产品经理给出的原型制作静态页面。
后端团队:20人,实现产品功能。
测试团队:5人,测试所有的功能。
运维团队:3人,项目的发布以及维护。
- 后台管理系统工程搭建
- Maven
- 依赖管理、jar包、工程之间的依赖。
- 项目构建。实现项目的一步构建。
- 工程聚合、继承、依赖。
-
- Maven的工程类型:
- war包工程
- Jar包工程
- Pom工程。
-
- 父工程的搭建
父工程应该是一个pom工程。在父工程中定义依赖的jar包的版本信息。Maven插件的版本。
-
-
- 安装本地仓库
-
使用.m2覆盖本地仓库的内容。
-
-
- 创建maven工程
-
-
-
- 修改pom文件
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.taotao</groupId>
<artifactId>taotao-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<!-- 集中定义依赖版本号 -->
<properties>
<junit.version>4.12</junit.version>
<spring.version>4.1.3.RELEASE</spring.version>
<mybatis.version>3.2.8</mybatis.version>
<mybatis.spring.version>1.2.2</mybatis.spring.version>
<mybatis.paginator.version>1.2.15</mybatis.paginator.version>
<mysql.version>5.1.32</mysql.version>
<slf4j.version>1.6.4</slf4j.version>
<jackson.version>2.4.2</jackson.version>
<druid.version>1.0.9</druid.version>
<httpclient.version>4.3.5</httpclient.version>
<jstl.version>1.2</jstl.version>
<servlet-api.version>2.5</servlet-api.version>
<jsp-api.version>2.0</jsp-api.version>
<joda-time.version>2.5</joda-time.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
<commons-io.version>1.3.2</commons-io.version>
<commons-net.version>3.3</commons-net.version>
<pagehelper.version>3.4.2-fix</pagehelper.version>
<jsqlparser.version>0.9.1</jsqlparser.version>
<commons-fileupload.version>1.3.1</commons-fileupload.version>
<jedis.version>2.7.2</jedis.version>
<solrj.version>4.10.3</solrj.version>
</properties>
<!-- 只定义依赖的版本,并不实际依赖 -->
<dependencyManagement>
<dependencies>
<!-- 时间操作组件 -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
</dependency>
<!-- Apache工具组件 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>${commons-net.version}</version>
</dependency>
<!-- Jackson Json处理工具包 -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
<!-- 单元测试 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- 日志处理 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- Mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis.spring.version}</version>
</dependency>
<dependency>
<groupId>com.github.miemiedev</groupId>
<artifactId>mybatis-paginator</artifactId>
<version>${mybatis.paginator.version}</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>${pagehelper.version}</version>
</dependency>
<!-- MySql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- 连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- JSP相关 -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>${jsp-api.version}</version>
<scope>provided</scope>
</dependency>
<!-- 文件上传组件 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons-fileupload.version}</version>
</dependency>
<!-- Redis客户端 -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
<!-- solr客户端 -->
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>${solrj.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- 资源文件拷贝插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- java编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- 配置Tomcat插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
-
- 创建一个common工程
也需要继承taotao-parent工程。
-
-
- 创建工程
-
-
-
- Pom文件
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.taotao</groupId> <artifactId>taotao-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>com.taotao</groupId> <artifactId>taotao-common</artifactId> <version>0.0.1-SNAPSHOT</version> <!-- jar包的依赖 --> <dependencies> <!-- 时间操作组件 --> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> </dependency> <!-- Apache工具组件 --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-io</artifactId> </dependency> <dependency> <groupId>commons-net</groupId> <artifactId>commons-net</artifactId> </dependency> <!-- Jackson Json处理工具包 --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency> <!-- httpclient --> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> </dependency> <!-- 单元测试 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> <!-- 日志处理 --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </dependency> </dependencies> </project> |
-
- 后台管理工程创建
搭建一个聚合工程:
-
-
- 工程结构
-
传统工程结构:
Maven管理的工程结构:
不使用maven:工程部署时需要手动复制jar包。完成工程构建。非常繁琐。
使用maven进行工程构建:
使用maven可以实现一步构建。
项目结构图:
后台管理系统工程结构:
taotao-parent -- 管理依赖jar包的版本,全局,公司级别
|--taotao-common --- 通用组件、工具类
|--taotao-manage -- 后台系统
|--com.taotao.manage.web
|--com.taotao.manage.service
|--com.taotao.manage.mapper
|--com.taotao.manage.pojo
-
-
- Taotao-manager工程
- 工程搭建
- Taotao-manager工程
-
-
-
-
- 修改pom文件
-
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.taotao</groupId> <artifactId>taotao-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>com.taotao</groupId> <artifactId>taotao-manager</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <!-- 依赖管理 --> <dependencies> <dependency> <groupId>com.taotao</groupId> <artifactId>taotao-common</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> </dependencies> </project> |
-
-
- Taotao-manager-pojo模块
- 创建工程
- Taotao-manager-pojo模块
-
-
-
-
- Pom文件
-
-
不需要修改,taotao-manager-pojo模块不依赖任何jar包。
-
-
- Taotao-manager-mapper模块
- 创建工程
- Taotao-manager-mapper模块
-
-
-
-
- Pom文件修改
-
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.taotao</groupId> <artifactId>taotao-manager</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>taotao-manager-mapper</artifactId> <!-- 依赖管理 --> <dependencies> <dependency> <groupId>com.taotao</groupId> <artifactId>taotao-manager-pojo</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <!-- Mybatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> </dependency> <dependency> <groupId>com.github.miemiedev</groupId> <artifactId>mybatis-paginator</artifactId> </dependency> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> </dependency> <!-- MySql --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- 连接池 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> </dependency> </dependencies> </project> |
-
-
- Taotao-manager-service模块
- 创建工程
- Taotao-manager-service模块
-
-
-
-
- Pom文件
-
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.taotao</groupId> <artifactId>taotao-manager</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>taotao-manager-service</artifactId> <!-- 依赖管理 --> <dependencies> <dependency> <groupId>com.taotao</groupId> <artifactId>taotao-manager-mapper</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> </dependency> </dependencies> </project> |
-
-
- Taotao-manager-web模块
- 创建工程
- Taotao-manager-web模块
-
-
-
-
- Pom文件
-
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.taotao</groupId> <artifactId>taotao-manager</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>taotao-manager-web</artifactId> <packaging>war</packaging> <!-- 依赖管理 --> <dependencies> <dependency> <groupId>com.taotao</groupId> <artifactId>taotao-manager-service</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <!-- JSP相关 --> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <scope>provided</scope> </dependency> <!-- 文件上传组件 --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> </dependency> </dependencies> </project> |
-
-
-
- 创建web.xml
-
-
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="taotao" version="2.5"> <display-name>taotao-manager</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list>
</web-app> |
- 测试maven工程
- 运行的工程
要运行工程,需要运行聚合工程也就是taotao-manager。
-
- Tomcat插件
在taotao-manager工程的pom文件中添加如下内容:
<build> <!-- 配置插件 --> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <port>8080</port> <path>/</path> </configuration> </plugin> </plugins> </build> |
-
- 启动工程
使用maven命令:
clean tomcat7:run
tomcat7指定使用tomcat7的插件。
注意:
- 需要把taotao-parent工程安装到本地仓库。Install
- 需要把taotao-common安装到本地仓库。
- Svn
地址:https://PC-201311301552/svn/taotao-javaee16/
用户名:user
密码:user