springcloud--ruul(路由网关)
Posted 聂鑫磊
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springcloud--ruul(路由网关)相关的知识,希望对你有一定的参考价值。
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);
}
}
以上是关于springcloud--ruul(路由网关)的主要内容,如果未能解决你的问题,请参考以下文章