Zuul的主要功能就是路由转发和过滤器

实例:

1:添加依赖pom.xml:

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
</dependencies>

2:配置文件:

server:
port: 8888
spring:
application:
name: zuul-gateway
eureka:
client:
service-url:
defaultZone: http://localhost:9001/eureka/
instance:
instance-id: zuul-8888
prefer-ip-address: true
zuul:
prefix: /nxl
ignored-services: "*" #屏蔽指定的服务
routes:
hello-route:
#微服务名字,提供者的名字
service-id: provider-one
path: /aaa/**

3:启动类:

@SpringBootApplication
@EnableZuulProxy
public class App {

public static void main(String[] args) {

SpringApplication.run(App.class, args);

}

}

posted on 2018-09-28 19:15  聂鑫磊  阅读(441)  评论(0编辑  收藏  举报