1. gateway 引入 nacos 依赖,实现服务的注册发现

2. gateway 引入 loadbalancer 依赖,实现服务的负载均衡
This commit is contained in:
YunaiV
2022-06-02 23:43:34 +08:00
parent 9bb0422c1c
commit 94d62b8d79
5 changed files with 33 additions and 7 deletions

View File

@@ -0,0 +1,9 @@
server:
port: 8888
--- #################### 注册中心相关配置 ####################
spring:
cloud:
nacos:
server-addr: 127.0.0.1:8848

View File

@@ -1,7 +1,10 @@
server:
port: 8888
spring:
application:
name: gateway-server
profiles:
active: local
cloud:
# Spring Cloud Gateway 配置项,对应 GatewayProperties 类
gateway:
@@ -20,6 +23,6 @@ spring:
filters: # 过滤器,对请求进行拦截,实现自定义的功能,对应 FilterDefinition 数组
- StripPrefix=1
- id: system-admin-api # 路由的编号
uri: http://127.0.0.1:48080 # 路由的目标地址
uri: lb://system-server
predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
- Path=/admin-api/system/**