SpringCloud-Zuul简单使用
引入依赖(注意版本)
spring-cloud-dependencies、spring-cloud-starter-netflix-eureka-client、spring-cloud-starter-netflix-zuul、spring-cloud-starter-actuator、spring-boot-test-starter
引入版本管理依赖
spring-cloud-dependencies
开启代理
@EnableDiscoveryClient
@EnableZuulProxy
配置文件
spring.application.name: hellp-client-zuul
spring.port: 8080
eureka.client.serviceUrl.defaultZone: http://localhost:8761/eureka/
#匹配url 请求到该网关的所有hello下链接转发到对应服务
zuul.routes.hello.path: /hello/**
#匹配上面url的转发到对应注册中心的hello-eureka-client应用服务
zuul.routes.hello.serviceId: hello-eureka-client
zuul.routes.data.path: /data/**
zuul.routes.data.serviceId: data-eureka-client