1. gateway 引入 nacos 依赖,实现服务的注册发现
2. gateway 引入 loadbalancer 依赖,实现服务的负载均衡
This commit is contained in:
parent
9bb0422c1c
commit
94d62b8d79
@ -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",
|
||||
|
||||
|
@ -16,11 +16,24 @@
|
||||
<url>https://github.com/YunaiV/yudao-cloud</url>
|
||||
|
||||
<dependencies>
|
||||
<!-- 引入 Spring Cloud Gateway 相关依赖,使用它作为网关,并实现对其的自动配置 -->
|
||||
<!-- Gateway 网关相关 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RPC 远程调用相关 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Registry 注册中心相关 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
9
yudao-gateway/src/main/resources/application-local.yaml
Normal file
9
yudao-gateway/src/main/resources/application-local.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
server:
|
||||
port: 8888
|
||||
|
||||
--- #################### 注册中心相关配置 ####################
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
server-addr: 127.0.0.1:8848
|
@ -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/**
|
||||
|
Loading…
Reference in New Issue
Block a user