文章大纲
一 、第十天课程计划
二、域名访问系统
三、什么是nginx
四、nginx的应用场景
五、nginx的使用
六、nginx配置虚拟主机
七、nginx配置反向代理
八、nginx配置负载均衡
九、nginx的高可用(了解)
十、SSO系统
十一、SSO系统的实现

淘淘商城课程大纲

课程大纲
一共14天课程
(1)第一天:电商介绍–互联网术语-SOA-分布式-集群介绍-环境配置-框架搭建
(2)第二天:Dubbo介绍_dubbo框架整合_商品列表查询实现_分页_逆向工程
(3)第三天:Git&.Nginx,类目选择,新增商品
(4)第四天:门户网站介绍&商城首页搭建&内容系统创建&CMS实现
(5)第五天:首页轮播图显示实现,Redis环境搭建,Redis实现缓存
(6)第六天:solr索引库搭建&solr搜索功能实现&图片显示问题解决
(7)第七天:solr集群搭建_全局异常处理
(8)第八天:activeMQ介绍_搭建_解决同步索引库问题
(9)第九天:FreeMark入门_静态化页面标签介绍_静态化页面实现
(10)第十天:Nginx代理详解…单点登录系统工程搭建_接口文档讲解
(11)第十一天:SSO系统的搭建&单点登录系统实现_用户名回显_cookie跨域问题
(12)第十二天:购物车订单系统的实现。
(13)第十三天:订单提交的功能实现&项目的部署&服务器的域名规划。
(14)项目总结。

1 课程计划

	Nginx的安装
	Nginx配置虚拟主机
	Nginx实现反向代理
	Nginx实现负载均衡
	SSO系统工程搭建

2 域名访问系统

2.1 目前访问系统存在的问题

目前访问后台系统:
http://localhost:8081/
目前访问首页系统:
http://localhost:8082/
目前访问搜索结果页面:
http://localhost:8085
在搜索结果页面search.jsp中,代码中写死了其他的系统的全路径。
在这里插入图片描述

问题:

1.localhost只能访问本地,不能访问其他的服务器;
系统应当要部署在测试环境和生产环境。

可以使用ip地址?
 
2.开发环境的ip地址和测试环境的ip地址是不一样的。每次环境变化的时候,都需要修改访问的ip地址

3.页面加载资源或者请求其他系统的URL时,使用了全路径,一旦环境发生改变,资源无法加载,请求无法访问。

4.ip地址没有意义,不容易记忆,用户不会通过ip地址进行访问,一般通过域名访问。

2.2 使用域名访问

例如:访问本地开发环境下的商品详情页面:

修改本机hosts文件:
在这里插入图片描述

访问地址:http://item.taotao.com:8086/item/536563.html,

存在的问题:
访问时域名后还需要加上端口。

可以使用nginx进行配置,达到只使用域名访问的目的。

3 什么是nginx

Nginx是一款高性能的http 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器。由俄罗斯的程序设计师Igor Sysoev用c语言所开发,官方测试nginx能够支支撑5万并发链接,并且cpu、内存等资源消耗却非常低,运行非常稳定。开源。

4 nginx的应用场景

1、http服务器。Nginx是一个http服务可以独立提供http服务。可以做网页静态服务器。
2、虚拟主机。可以实现在一台服务器虚拟出多个网站。例如个人网站使用的虚拟主机。
3、反向代理,负载均衡。当网站的访问量达到一定程度后,单台服务器不能满足用户的请求时,需要用多台服务器集群可以使用nginx做反向代理。并且多台服务器可以平均分担负载,不会因为某台服务器负载高宕机而某台服务器闲置的情况。

5 nginx的使用

5.1 nginx的安装

下载nginx:

官方网站:
http://nginx.org/
使用的版本是1.8.0版本。
在这里插入图片描述

Nginx提供的是源码。

5.2 安装要求的环境

1、需要安装gcc的环境。

yum -y install gcc-c++

2、第三方的开发包。
PCRE
PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库。

yum install -y pcre pcre-devel

注:pcre-devel是使用pcre开发的一个二次开发库。nginx也需要此库。
zlib
zlib库提供了很多种压缩和解压缩的方式,nginx使用zlib对http包的内容进行gzip,所以需要在linux上安装zlib库。

yum install -y zlib zlib-devel

openssl
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。
nginx不仅支持http协议,还支持https(即在ssl协议上传输http),所以需要在linux安装openssl库。

yum install -y openssl openssl-devel

5.3 安装步骤

第一步:把nginx的源码包上传到linux系统
第二步:解压缩

[root@localhost ~]# tar -xvf nginx-1.8.0.tar.gz 

第三步:
目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录:

mkdir /var/temp/nginx/client -p

第四步:使用configure命令创建一makeFile文件。
直接运行下面这一段

./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi

第四步:编译,使用:make

第五步:make install

在这里插入图片描述

5.4 启动nginx

进入sbin目录

[root@localhost sbin]# ./nginx 

在这里插入图片描述

5.5 测试访问nginx

浏览器输入:192.168.25.148
在这里插入图片描述

访问的默认端口是80端口。注意:看是否关闭防火墙。

5.6 nginx的3个命令

启动命令

./nginx

关闭命令

./nginx -s stop 和
./nginx -s quit

刷新配置文件

./nginx -s reload

修改了nginx.conf文件之后,可以不重启Nginx,能马上生效

6 nginx配置虚拟主机

虚拟的主机就是在一台服务器启动多个网站。

如何区分不同的网站:
1、端口不同
2、域名不同

6.1 通过端口区分不同的虚拟的主机

Nginx的配置文件配置项解释如下:
/usr/local/nginx/conf/nginx.conf

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
    }
}

可以配置多个server,配置了多个虚拟的主机。可以使用vim命令来修改,但是比较麻烦。
可以使用工具远程修改。

使用xftp配置远程编辑器
直接使用VIM命令不太方便,一般需要修改远程工程中的文件,除了使用vim命令外,还可以配置文本编辑器,直接作用于远程文件。

第一步:使用xshell连接到虚拟机,先新建远程文件输出
第二步:选择选项
在这里插入图片描述

第三步:选择高级》取消勾选 》 点击… (选择文本编辑的可运行文件)
在这里插入图片描述

第四步:使用

在这里插入图片描述

添加配置虚拟主机
修改nginx的配置文件,如下:
/usr/local/nginx/conf/nginx.conf

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
    }
    server {
        listen       81;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html-81;
            index  index.html index.htm;
        }
    }
}

修改完成需要每次配置文件修改之后都需要重新加载配置文件

[root@localhost nginx]# sbin/nginx -s reload

6.2 通过域名区分不同的虚拟的主机

什么是域名
域名就是网站。
www.baidu.com
www.taobao.com
www.jd.com

一级域名:又叫顶级域名
Baidu.com
Taobao.com
Jd.com
二级域名:
www.baidu.com
Image.baidu.com
Item.baidu.com
三级域名:
1.Image.baidu.com
Aaa.image.baidu.com

域名访问网站,其本质还是通过Tcp/ip协议访问,如图:以下为通过域名访问的流程图:
在这里插入图片描述

DNS服务器:把域名解析为ip地址。保存的就是域名和ip的映射关系,可以简单的理解为一个MAP<KEY,VALUE>

一个域名对应一个ip地址,一个ip地址可以被多个域名绑定。

本地测试可以修改host文件。

修改window的hosts文件:(C:\Windows\System32\drivers\etc)
可以配置域名和ip的映射关系,如果hosts文件中配置了域名和ip的对应关系,不需要走DNS服务器。

手动修改hosts文件比较麻烦,一般企业中使用hosts切换的工具:switchhosts 来方便切换hosts文件中的配置。
使用时必须以管理员权限运行。
在这里插入图片描述

在这里插入图片描述

配置域名
修改nginx的配置文件,如下:

/usr/local/nginx/conf/nginx.conf
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen        80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
    }
    server {
        listen       81;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html-81;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  www.taobao.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html-taobao;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  www.baidu.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html-baidu;
            index  index.html index.htm;
        }
    }
}

添加本地域名映射关系:
域名的配置:在使用switchhosts 添加如下,并应用。

192.168.25.148 www.taobao.com
192.168.25.148 www.baidu.com

在这里插入图片描述

7 nginx配置反向代理

7.1 什么是反向代理

正向代理
在这里插入图片描述

反向代理:

在这里插入图片描述

反向代理服务器决定哪台服务器提供服务。
反向代理服务器不提供服务器。也只是请求的转发。

7.2 Nginx实现反向代理

两个域名指向同一台nginx服务器,用户访问不同的域名显示不同的网页内容。
两个域名是www.sina.com.cn和www.sohu.com
nginx服务器使用虚拟机192.168.25.148
在这里插入图片描述

操作步骤:
第一步:安装两个tomcat,分别运行在8080和8081端口。
第二步:启动两个tomcat。
第三步:反向代理服务器的配置,在/usr/local/nginx/conf/nginx.conf中http节点中配置:

upstream tomcat1 {
server 192.168.25.148:8080;
}
server {
    listen       80;
    server_name  www.sina.com.cn;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        proxy_pass   http://tomcat1;
        index  index.html index.htm;
    }
}
upstream tomcat2 {
server 192.168.25.148:8081;
}
server {
    listen       80;
    server_name  www.sohu.com;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        proxy_pass   http://tomcat2;
        index  index.html index.htm;
    }
}

第四步:nginx重新加载配置文件

./nginx -s reload

第五步:在本地配置域名

在hosts文件中添加域名和ip的映射关系,可使用switchhosts来设置
192.168.25.148 www.sina.com.cn
192.168.25.148 www.sohu.com

7.3 使用域名来访问系统改造

1.先配置本地域名和ip地址的映射:
在这里插入图片描述

2.可使用本地windows版本的nginx 配置nginx.conf,添加server节点如下:

 upstream tomcat1 {
server 127.0.0.1:8082;
 }	 

server {
    listen       80;
    server_name  www.taotao.com;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;
    location / {
        proxy_pass   http://tomcat1;
        index  index.html index.htm;
    }


    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

3.windows下启动nginx
双击exe

4.查看测试效果:
在这里插入图片描述

8 nginx配置负载均衡

如果一个服务由多台服务器提供,需要把负载分配到不同的服务器处理,需要负载均衡。

 upstream tomcat2 {
	server 192.168.25.148:8081;
	server 192.168.25.148:8082;
  }

默认的负载均衡的策略就是轮询的方式。

可以根据服务器的实际情况调整服务器权重。权重越高分配的请求越多,权重越低,请求越少。默认是都是1

 upstream tomcat2 {
	server 192.168.25.148:8081;
	server 192.168.25.148:8082 weight=2;
    }

其他的负载均衡的策略:1.通过IP地址的hash值 做映射。2.通过URL的方式计算出Hash值 。3.随机策略。4.最少并发量。

9 nginx的高可用(了解)

9.1 什么是负载均衡高可用

nginx作为负载均衡器,所有请求都到了nginx,可见nginx处于非常重点的位置,如果nginx服务器宕机后端web服务将无法提供服务,影响严重。
为了屏蔽负载均衡服务器的宕机,需要建立一个备份机。主服务器和备份机上都运行高可用(High Availability)监控程序,通过传送诸如“I am alive”这样的信息来监控对方的运行状况。当备份机不能在一定的时间内收到这样的信息时,它就接管主服务器的服务IP并继续提供负载均衡服务;当备份管理器又从主管理器收到“I am alive”这样的信息时,它就释放服务IP地址,这样的主服务器就开始再次提供负载均衡服务。

9.2 keepalived+nginx实现主备

什么是keepalived
keepalived是集群管理中保证集群高可用的一个服务软件,用来防止单点故障。
Keepalived的作用是检测web服务器的状态,如果有一台web服务器死机,或工作出现故障,Keepalived将检测到,并将有故障的web服务器从系统中剔除,当web服务器工作正常后Keepalived自动将web服务器加入到服务器群中,这些工作全部自动完成,不需要人工干涉,需要人工做的只是修复故障的web服务器。

keepalived工作原理
keepalived是以VRRP协议为实现基础的,VRRP全称Virtual Router Redundancy Protocol,即虚拟路由冗余协议。
虚拟路由冗余协议,可以认为是实现路由器高可用的协议,即将N台提供相同功能的路由器组成一个路由器组,这个组里面有一个master和多个backup,master上面有一个对外提供服务的vip(VIP = Virtual IP Address,虚拟IP地址,该路由器所在局域网内其他机器的默认路由为该vip),master会发组播,当backup收不到VRRP包时就认为master宕掉了,这时就需要根据VRRP的优先级来选举一个backup当master。这样的话就可以保证路由器的高可用了。
keepalived主要有三个模块,分别是core、check和VRRP。core模块为keepalived的核心,负责主进程的启动、维护以及全局配置文件的加载和解析。check负责健康检查,包括常见的各种检查方式。VRRP模块是来实现VRRP协议的。

详细参考:Keepalived权威指南中文.pdf

keepalived+nginx实现主备过程

初始状态
在这里插入图片描述

主机宕机
在这里插入图片描述

主机恢复
在这里插入图片描述

高可用环境
两台nginx,一主一备:192.168.101.3和192.168.101.4
两台tomcat服务器:192.168.101.5、192.168.101.6

安装keepalived

分别在主备nginx上安装keepalived,参考“安装手册”进行安装:

在这里插入图片描述

10 SSO系统

10.1 什么是SSO系统

SSO英文全称Single Sign On,单点登录。SSO是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。它包括可以将这次主要的登录映射到其他应用中用于同一个用户的登录的机制。它是目前比较流行的企业业务整合的解决方案之一。

10.2 为什么要有单点登录系统

传统的登录实现方式
在这里插入图片描述

此方式在只有一个web工程时是没有问题。

集群环境下
在这里插入图片描述

集群环境下会出现要求用户多次登录的情况。
解决方案:

1、配置tomcat集群。配置tomcatSession复制。节点数不要超过5个。
2、可以使用Session服务器,保存Session信息,使每个节点是无状态。需要模拟Session。

单点登录系统是使用redis模拟Session,实现Session的统一管理,解决Session的共享问题.

11 SSO系统的实现

系统架构图:

在这里插入图片描述

需要创建一个sso服务工程,可以参考taotao-manager创建。

11.1 工程搭建

Taotao-sso(pom聚合工程)
   |--taotao-sso-interface(jar)
   |--taotao-sso-Service(war)
Taotao-sso-web(war)

可以参考taotao-manager,taotao-manager-web创建

11.2 Taotao-sso

在这里插入图片描述

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>
    <modules>
        <module>taotao-sso-interface</module>
        <module>taotao-sso-service</module>
    </modules>
    <parent>
        <groupId>com.taotao</groupId>
        <artifactId>taotao-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.taotao</groupId>
    <artifactId>taotao-sso</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>


    <dependencies>
        <!-- 依赖taotao-common -->
        <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-common</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!-- 配置tomcat插件 -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <configuration>
                    <port>8087</port>
                    <path>/</path>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

11.3 taotao-sso-interface

在这里插入图片描述
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-sso</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>taotao-sso-interface</artifactId>
    <dependencies>
        <!-- 依赖taotao-manager-pojo -->
        <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-manager-pojo</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

11.4 taotao-sso-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-sso</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>taotao-sso-service</artifactId>
    <packaging>war</packaging>
    <dependencies>
        <!-- 添加接口的依赖 -->
        <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-sso-interface</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-manager-dao</artifactId>
            <version>1.0-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>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
        </dependency>
        <!-- dubbo相关 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <!-- 排除依赖 -->
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jboss.netty</groupId>
                    <artifactId>netty</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.sgroschupf</groupId>
            <artifactId>zkclient</artifactId>
        </dependency>
        <!-- redis -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!-- 配置打包时跳过测试 ,首次配置使用的时候会自动联网进行下载 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <!-- 跳过测试 -->
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

11.5 框架整合
在这里插入图片描述

11.6 表现层工程

表现层工程包含登录和注册页面,需要调用sso服务实现。
给app提供服务,restful形式的服务。
Taotao-sso-web(war包)
可以参考taotao-manager-web创建。

<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>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.taotao</groupId>
    <artifactId>taotao-sso-web</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <!-- manager-interface接口 -->
        <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-sso-interface</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <!-- manager-interface接口 -->
        <!-- <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-manager-interface</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>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
        </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>
        <!-- dubbo相关 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <!-- 排除依赖 -->
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jboss.netty</groupId>
                    <artifactId>netty</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.sgroschupf</groupId>
            <artifactId>zkclient</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!-- 配置tomcat插件 -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <configuration>
                    <port>8088</port>
                    <path>/</path>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

在这里插入图片描述

后续

学习这一天的时候,我买了阿里云服务器和域名,试了试以前做的项目,用到Nginx反向代理,就想要是早点用到云服务器和域名就好了,不用再设置本机Host文件等等,感觉挺复杂的。。。。
主要还是学习技术,这个项目目前还是用端口访问和Linux的方式,以后学完这一部分有时间了再改域名和端口,直接挂到云主机上,期待。。手动狗头!!

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐