From 94d62b8d798a4f0c17fee706d112319633d15740 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 2 Jun 2022 23:43:34 +0800 Subject: [PATCH] =?UTF-8?q?1.=20gateway=20=E5=BC=95=E5=85=A5=20nacos=20?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=EF=BC=8C=E5=AE=9E=E7=8E=B0=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=9A=84=E6=B3=A8=E5=86=8C=E5=8F=91=E7=8E=B0=202.=20gateway=20?= =?UTF-8?q?=E5=BC=95=E5=85=A5=20loadbalancer=20=E4=BE=9D=E8=B5=96=EF=BC=8C?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=9C=8D=E5=8A=A1=E7=9A=84=E8=B4=9F=E8=BD=BD?= =?UTF-8?q?=E5=9D=87=E8=A1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http-client.env.json | 1 + yudao-gateway/pom.xml | 15 ++++++++++++++- ...ication.java => GatewayServerApplication.java} | 4 ++-- .../src/main/resources/application-local.yaml | 9 +++++++++ yudao-gateway/src/main/resources/application.yaml | 11 +++++++---- 5 files changed, 33 insertions(+), 7 deletions(-) rename yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/{YudaoGatewayApplication.java => GatewayServerApplication.java} (68%) create mode 100644 yudao-gateway/src/main/resources/application-local.yaml diff --git a/http-client.env.json b/http-client.env.json index cfdc7f030..9333edc52 100644 --- a/http-client.env.json +++ b/http-client.env.json @@ -12,6 +12,7 @@ }, "gateway": { "baseUrl": "http://127.0.0.1:8888/admin-api", + "systemBaseUrl": "http://127.0.0.1:8888/admin-api", "token": "test1", "adminTenentId": "1", diff --git a/yudao-gateway/pom.xml b/yudao-gateway/pom.xml index 61e28a027..6df6ba494 100644 --- a/yudao-gateway/pom.xml +++ b/yudao-gateway/pom.xml @@ -16,11 +16,24 @@ https://github.com/YunaiV/yudao-cloud - + org.springframework.cloud spring-cloud-starter-gateway + + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + diff --git a/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/YudaoGatewayApplication.java b/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/GatewayServerApplication.java similarity index 68% rename from yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/YudaoGatewayApplication.java rename to yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/GatewayServerApplication.java index ef9e8e4b6..d5904db49 100644 --- a/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/YudaoGatewayApplication.java +++ b/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/GatewayServerApplication.java @@ -4,10 +4,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class YudaoGatewayApplication { +public class GatewayServerApplication { public static void main(String[] args) { - SpringApplication.run(YudaoGatewayApplication.class, args); + SpringApplication.run(GatewayServerApplication.class, args); } } diff --git a/yudao-gateway/src/main/resources/application-local.yaml b/yudao-gateway/src/main/resources/application-local.yaml new file mode 100644 index 000000000..386065760 --- /dev/null +++ b/yudao-gateway/src/main/resources/application-local.yaml @@ -0,0 +1,9 @@ +server: + port: 8888 + +--- #################### 注册中心相关配置 #################### + +spring: + cloud: + nacos: + server-addr: 127.0.0.1:8848 diff --git a/yudao-gateway/src/main/resources/application.yaml b/yudao-gateway/src/main/resources/application.yaml index 90cf4675e..722e5dbb4 100644 --- a/yudao-gateway/src/main/resources/application.yaml +++ b/yudao-gateway/src/main/resources/application.yaml @@ -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/**