700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > SpringCloud Greenwich(三)注册中心之zookeeper Zuul和 gateway网关配置

SpringCloud Greenwich(三)注册中心之zookeeper Zuul和 gateway网关配置

时间:2023-05-30 17:05:49

相关推荐

SpringCloud Greenwich(三)注册中心之zookeeper Zuul和 gateway网关配置

本项目是搭建基于zookeeper注册中心的springcloud,使用zuul网关和gateway网关

一、框架搭建

(1)项目结构

micro-service 服务提供者

zuul-gateway zuul网关

springcloud-gatewaygateway网关

(2)环境

zookeeper3.6.2

springboot 2.1.9

springcloudGreenwich

二、项目配置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: 120000ribbon: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: 120000ribbon:ReadTimeout: 240000ConnectTimeout: 2000MaxAutoRetries: 0MaxAutoRetriesNextServer: 1eager-load:enabled: trueclients: micro-service

zookeeper注册路径

三、项目地址

/90duc/springcloud-zookeeper

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。