Step 3-1:新建service-zuul
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