spring cloud 開發記錄

spring cloud bus
 /buf-refresh能夠手動刷新配置,通過webhook 鉤子方法 /monitor 無法刷新配置

在application.yml中添加,不要在bootstrap中添加,會啓動失敗。
spring:
  cloud:
    bus:
      id: ${vcap.application.name:${spring.application.name:application}}:${vcap.application.instance_index:${spring.cloud.config.profile:${local.server.port:${server.port:0}}}}:${vcap.application.instance_id:${random.value}}


參考文章:https://blog.csdn.net/qq_31987435/article/details/96474490


Gateway 網管配置
spring:
  cloud:
    config:
      uri: http://192.168.1.3:8888
      profile: dev
      label: dev
      name: cloud-zookeeper,cloud-gateway
    gateway:
      routes:
        -  id: user-service
           uri: lb://user-service  #lb表示 從註冊中心獲取
           predicates:
             - Path=/api/user/**   #路由地址 http://user-service/api/user/zhangsan
           filters:
              - StripPrefix=2     #去掉路由地址前綴/api/user,這裏加了2個path所以去掉2個,得到原始地址http://user-service/zhangsan
        - id: department-service
          uri: lb://department-service
          predicates:
              Path=/dep/**
          filters:
             - StripPrefix=1  #去掉路由地址前綴/dep,這裏去掉1個,得到原始地址http://department-service/it




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章