springcloud gateway(一)

pom.xml

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Finchley.SR2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

导入gateway的jar,以及eureka的jar

 

application.yml

spring:
  cloud:
    gateway:
      routes:
        - id: web
          uri: lb://EURAKA-SERVER
          predicates:
            - Path=/hello/{segment}


  application:
    name: springcloud-gateway
    cloud:
      gateway:
        discovery:
          locator:
            enabled: true
#系统端口
server:
  port: 1200

#Eureka配置
eureka:
  client:
    service-url:
      defaultZone: http://localhost:10001/eureka/

 

其中这一段比较重要

spring:
  cloud:
    gateway:
      routes:
        - id: web
          uri: lb://EURAKA-SERVER
          predicates:
            - Path=/hello/{segment}

lb代表后面写入的是服务名,如果uri你写入http://localhost:1200,那么它转发的是到特定的端口号,而不会说转发到特定的服务名,这里注意一下。

 

其次上面这段什么意思呢?

当匹配到http://localhost:1200/hello/xx的时候会跳转到服务名为euraka-server的服务去。

 

限流

http://www.ityouknow.com/springcloud/2019/01/26/spring-cloud-gateway-limit.html

熔断器使用hystrix,这个比较简单

 

 

比较重要的是它的过滤参数,比如header,cookie验证等等

http://www.ityouknow.com/springcloud/2019/01/19/spring-cloud-gateway-service.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值