Spring Gateway 1.0

本文介绍了Spring Gateway作为网关的角色,包括项目创建、匹配规则配置和注意事项。创建过程中涉及添加依赖、配置YML文件和启动类注解。匹配规则配置通过predicates实现,详细规则可参考官方文档。搭建时需要注意避免引入不必要的spring web依赖,以防止错误。
摘要由CSDN通过智能技术生成

Spring Gateway 网关

也是一个springboot项目,也是要注册到注册中心,提供统一对外地址,来处理请求分发到不同模块功能对应的服务,可以统一过滤请求等处理。但是如果模块功能的服务知道端口号和地址还是可以访问的。

Spring Gateway 项目创建

  1. 添加依赖
        <!--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>
  1. 设置yml文件

server:
  port: 9527

spring:
  application:
    name: cloud-gateway
  cloud:
    gateway:
      discovery:
        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值