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
  • 相关阅读:
    导航守卫
    Java内部类详解
    requestAnimationFrame,Web中写动画的另一种选择
    requestAnimationFrame
    Linux下文件的打包、解压缩指令——tar,gzip,bzip2
    selenium的动作链 actionchains
    列表存储内存的两种形式
    使用timeit模块 测试两种方式生成列表的所用的时间
    selenium访问百度 然后获取百度logo的截图
    python 666
  • 原文地址:https://www.cnblogs.com/xhzd/p/14977678.html
Copyright © 2011-2022 走看看