1、新建module:test-gateway
2、pom.xml加入路由依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
</dependency>
3、application.properties
server.port=55555
spring.application.name=api-gateway
zuul.routes.hello.path=/hello/**
zuul.routes.hello.serviceId=test-service
zuul.routes.consumer.path=/consumer/**
zuul.routes..consumer.serviceId=feign-consumer
#向注册中心注册自己
eureka.client.register-with-eureka=true
#检索服务
eureka.client.fetch-registry=true
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka
4、springboot启动类加上
@EnableZuulProxy 开启Zuul的API网关服务
@EnableDiscoveryClient