建立一个maven
pom.xml导入`
org.springframework.cloud
spring-cloud-starter-zuul
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>`
application.yml配置如下`server:
port: 8082
spring:
application:
name: TestZuul
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8520/eureka/
zuul:
routes:
api-a:
url: http://localhost:8080/
path: /user/**
service-id: TestBoot
strip-prefix: false`
其中zuul的URL代表要关联的子服务器端口,service-id表示端口的名字,即hostname