2、编写启动类org.springframework.cloud spring-cloud-starter-netflix-zuul
@SpringCloudApplication
@EnableZuulProxy //开启网关
public class GatewayApp {
public static void main(String[] args) {
SpringApplication.run(GatewayApp.class,args);
}
}
3、编写配置
server:
port: 10000 #服务端口
spring:
application:
name: api-gateway #指定服务名
4、编写路由规则
#代理(路由)规则
zuul:
routes:
user-service: #自定义路由的名称
path: /user-service/** # 自定义代理后的地址名称
serviceId: user-service # 指定服务名称
#url: http://127.0.0.1:8000 # 被代理的地址
consumer-demo: #自定义路由的名称
path: /consumer-demo/**
serviceId: consumer-demo # 指定服务名称
url: http://127.0.0.1:9000



