當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
SpringCloud Greenwich(三)注册中心之zookeeper、Zuul和 gateway网关配置
生活随笔
收集整理的這篇文章主要介紹了
SpringCloud Greenwich(三)注册中心之zookeeper、Zuul和 gateway网关配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
本項目是搭建基于zookeeper注冊中心的springcloud,使用zuul網關和gateway網關
一、框架搭建
(1)項目結構
micro-service? 服務提供者
zuul-gateway? zuul網關
springcloud-gateway??gateway網關
(2)環境
zookeeper?3.6.2
springboot 2.1.9
springcloud?Greenwich
?
二、項目配置application.yaml
192.168.31.188為本地zookeeper地址
(1)micro-service
spring:application:name: micro-serviceprofiles:active: devjackson:time-zone: GMT+8date-format: yyyy-MM-dd HH:mm:ssdefault-property-inclusion: ALWAYScloud:zookeeper:enabled: trueconnect-string: 192.168.31.188:2181discovery:enabled: trueroot: /services/springcloud-zookeeper #zookeeper中的根路徑,即服務注冊路徑:${spring.cloud.zookeeper.config.root}/${spring.application.name}register: trueconfig:enabled: trueroot: /config/springcloud-zookeeper #zookeeper中的根路徑,即服務配置信息的路徑:${spring.cloud.zookeeper.config.root}/${spring.application.name},${spring.profiles.active}watcher:enabled: trueserver:port: 8081(2)zuul-gateway
spring:application:name: zuul-gatewayprofiles:active: devjackson:time-zone: GMT+8date-format: yyyy-MM-dd HH:mm:ssdefault-property-inclusion: ALWAYScloud:zookeeper:enabled: trueconnect-string: 192.168.31.188:2181discovery:enabled: trueroot: /services/springcloud-zookeeper #zookeeper中的根路徑,即服務注冊路徑:${spring.cloud.zookeeper.config.root}/${spring.application.name}register: trueconfig:enabled: trueroot: /config/springcloud-zookeeper #zookeeper中的根路徑,即服務配置信息的路徑:${spring.cloud.zookeeper.config.root}/${spring.application.name},${spring.profiles.active}watcher:enabled: trueserver:port: 8082zuul:strip-prefix: true #轉發路徑截斷匹配前綴 # prefix: "/api"add-proxy-headers: falseset-content-length: truesemaphore:max-semaphores: 600hystrix:command:default:execution:isolation:thread:timeoutInMilliseconds: 120000 ribbon:ReadTimeout: 240000ConnectTimeout: 2000MaxAutoRetries: 0MaxAutoRetriesNextServer: 1eager-load:enabled: trueclients: micro-service(3)?springcloud-gateway
spring:application:name: springcloud-gatewayprofiles:active: devjackson:time-zone: GMT+8date-format: yyyy-MM-dd HH:mm:ssdefault-property-inclusion: ALWAYScloud:zookeeper:enabled: trueconnect-string: 192.168.31.188:2181discovery:enabled: trueroot: /services/springcloud-zookeeper #zookeeper中的根路徑,即服務注冊路徑:${spring.cloud.zookeeper.config.root}/${spring.application.name}register: trueconfig:enabled: trueroot: /config/springcloud-zookeeper #zookeeper中的根路徑,即服務配置信息的路徑:${spring.cloud.zookeeper.config.root}/${spring.application.name},${spring.profiles.active}watcher:enabled: truegateway:discovery:locator:enabled: truelower-case-service-id: truehttpclient:connect-timeout: 60000response-timeout: 5sroutes:- id: micro-service1uri: lb://micro-servicepredicates:- Path=/micro-service1/**filters:- StripPrefix=1- id: micro-service3uri: lb://micro-servicepredicates:- Path=/micro-service3/**filters:- PrefixPath=/microserver:port: 8083hystrix:command:default:execution:isolation:thread:timeoutInMilliseconds: 120000 ribbon:ReadTimeout: 240000ConnectTimeout: 2000MaxAutoRetries: 0MaxAutoRetriesNextServer: 1eager-load:enabled: trueclients: micro-servicezookeeper注冊路徑
?
三、項目地址
https://github.com/90duc/springcloud-zookeeper
總結
以上是生活随笔為你收集整理的SpringCloud Greenwich(三)注册中心之zookeeper、Zuul和 gateway网关配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 表白情话15字以内 唯美的表白情话短句有
- 下一篇: gradle idea java ssm