3Zuul 指定路由 · SpringCloud微服务实战 · 看云
3. 指定路由
导航
本节代码地址
GitHub: https://github.com/xuyisu/fw-sping-cloud/tree/master/fw-cloud-gateways/fw-cloud-gateways-zuul-simple
GitHub: https://github.com/xuyisu/fw-sping-cloud/tree/master/fw-cloud-ribbon/fw-cloud-ribbon-server
3.1 新建项目
3.2 新建启动类
记得开启@EnableZuulProxy注解
@EnableZuulProxy
@EnableDiscoveryClient
@SpringBootApplication
public class FwZuulApplication {
public static void main(String[] args) {
SpringApplication.run(FwZuulApplication.class, args);
}
}
3.3 应用配置
server:
port: 8679
spring:
application:
name: fw-gateways-zuul
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
zuul:
routes:
fw-cloud-ribbon-server:
path: /ribbon
当然还可以简写
zuul:
routes:
fw-cloud-ribbon-server:
path: /ribbon
也可以写成,path 可以省略
zuul:
routes:
fw-cloud-ribbon-server: /ribbon
3.4 启动项目
浏览器或Postman 输入localhost:8678/ribbon/user/1

