Zuul 搭建

Step 3-1:新建service-zuul

 

注:不熟悉如何搭建Spring Boot 项目,请点击

 

Step 3-2:在其入口applicaton类加上注解@EnableZuulProxy,开启zuul的功能:

@SpringBootApplication
@EnableZuulProxy
@EnableDiscoveryClient
public class ServiceZuulApplication {

    public static void main(String[] args) {
        SpringApplication.run(ServiceZuulApplication.class, args);
    }

}

 Step 3-3:加上配置文件application.yml加上以下的配置代码:

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
server:
  port: 8769
spring:
  application:
    name: service-zuul
zuul:
  routes:
    api-a:
      path: /api-a/**
      serviceId: service-ribbon
    api-b:
      path: /api-b/**
      serviceId: service-feign
    abc:
      path: /qwer/**
      serviceId: service-ribbon
    123:
      path: /123/**
      serviceId: service-feign

浏览器显示:

hi forezp,i am from port:8762

浏览器显示:

hi forezp,i am from port:8762

 

posted @ 2019-08-29 11:31  随风落木  阅读(2)  评论(0编辑  收藏  举报  来源