zoukankan      html  css  js  c++  java
  • springcloud gateway: discovery: locator: enabled: true 解释

    spring:
    application:
    name: gateway-server
    cloud:
    nacos:
    discovery:
    # server-addr: x.x.x.x:8848
    server-addr: 127.0.0.1:8848
    gateway:
    discovery:
    locator:
    enabled: true
     # 与服务注册与发现组件结合,设置为 true 后;id默认为微服务名称xxx-server;gatewayapplication有feign自动做负载均衡;
    不需要定制化显式配置;已生成默认的id=xservice,
    uri: lb://xserver , path=/serviceId/**

    参考:https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#glossary

    apigateway的两种方式

    spring:
    application:
    # 应用名称
    name: spring-gateway
    cloud:
    # 使用 Naoos 作为服务注册发现
    nacos:
    discovery:
    server-addr: 127.0.0.1:8848
    # 路由网关配置
    gateway:
    #开启网关拉取nacos的服务
    discovery:
    locator:
    enabled: false
    # 配置路由规则
    routes:
    # 采用自定义路由 ID(有固定用法,不同的 id 有不同的功能,详见:https://cloud.spring.io/spring-cloud-gateway/2.0.x/single/spring-cloud-gateway.html#gateway-route-filters)
    - id: nacos-provid
    # 采用 LoadBalanceClient 方式请求,以 lb:// 开头,后面的是注册在 Nacos 上的服务名
    uri: lb://nacos-provider
    # uri: http://localhost:7000
    # Predicate 翻译过来是“谓词”的意思,必须,主要作用是匹配用户的请求,有很多种用法
    predicates:
    # Method 方法谓词,这里是匹配 GET 和 POST 请求
    - Method=GET,POST
    - Path=/provider/test/** # 当你访问 http://localhost:9009/provider/ 的时候就会转发到 http://localhost:7000/provider/
    # - id: NACOS-CONSUMER-FEIGN
    # uri: lb://nacos-consumer-feign
    # predicates:
    # - Method=GET,POST
  • 相关阅读:
    【C#】解析C#中LING的使用
    【Android】解析Paint类中Xfermode的使用
    【Android】解析Paint类中MaskFilter的使用
    【C#】C#对电子邮件的收发操作
    【Linux】linux/unix下telnet提示Escape character is '^]'的意义
    【Linux】CentOs中yum与rpm区别
    【C#】C#对Excel表的操作
    【SqlServer】解析SqlServer中的事务
    【Android】Android传感器
    【SqlServer】SqlServer的异常处理
  • 原文地址:https://www.cnblogs.com/xhzd/p/14977678.html
Copyright © 2011-2022 走看看