1.简介
网关作为流量的入口,常用功能包括路由转发、权限校验、限流控制。
XML
spring:
cloud:
gateway:
routes:
- id: test_route
uri: http://www.baidu.com
predicates:
#访问的路径就是 如果是/hello?url=baidu 就转发到 https://www.baidu.com/hello?url=baidu
- Query=url,https://www.baidu.com
- id: test1_route
uri: http://www.hao123.com
predicates:
- Query=url,hao123
bootstrap.yml
XML
spring:
application:
name: gulimall-gateway
cloud:
nacos:
config:
server-addr: 192.168.2.36:8848
namespace: 255b4d7d-a41d-4340-b4e0-8fcb111fc978
group: dev
file-extension: yaml
nacos config
XML
spring:
application:
name: gulimall-gateway
cloud:
nacos:
discovery:
server-addr: 192.168.2.36:8848
server:
port: 88
导入的依赖
XML
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
详细的后面在介绍