Spring Gateway 网关
也是一个springboot项目,也是要注册到注册中心,提供统一对外地址,来处理请求分发到不同模块功能对应的服务,可以统一过滤请求等处理。但是如果模块功能的服务知道端口号和地址还是可以访问的。
Spring Gateway 项目创建
- 添加依赖
<!--gateway-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<!--eureka-client-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
- 设置yml文件
server:
port: 9527
spring:
application:
name: cloud-gateway
cloud:
gateway:
discovery: