赞
踩
目录
zuul网关本身也是一个微服务,需要注册到eureka中,完整依赖如下。
版本在父项目中统一定义
- <dependencies>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
- <exclusions>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
- </dependency>
- </dependencies>
proxy-1为代理名称
/proxy-1/**为代理请求路径(此类型路径会被代理)
serviceId为代理服务名称,注册在eureka中的服务名称
- spring:
- application:
- name: springcloud-zuul
-
- server:
- port: 9410
-
- eureka:
- instance:
- instance-id: springcloud-zuul1
- appname: ${spring.application.name}
- prefer-ip-address: true
- lease-renewal-interval-in-seconds: 5
- lease-expiration-duration-in-seconds: 5
- client:
- service-url:
- defaultZone: http://test1:9110/eureka/,http://test2:9120/eureka/
-
-
- zuul:
- routes:
- proxy-1:
- path: /proxy-1/**
- serviceId: springcloud-common
-
-
- @SpringBootApplication
- @EnableEurekaClie
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。