准备工作
需要两个项目去实现路由
demo1为springboot项目用于接入网关,测试网关连通性
gateway为网关路由项目
网关搭建
1.电脑安装好zookeeper,并且正常运行服务
Zookeeper官网
2.创建一个spring cloud gateway项目,并引入zookeeper功能
pom文件配置
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
<exclusions>