1. gateway:接入 nacos 配置中心,可支持动态路由
2. system-server:接入 nacos 配中心
This commit is contained in:
@@ -2,12 +2,21 @@ package cn.iocoder.yudao.gateway;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@SpringBootApplication
|
||||
public class GatewayServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GatewayServerApplication.class, args);
|
||||
// SpringApplication.run(GatewayServerApplication.class, args);
|
||||
|
||||
// 启动 Spring Boot 应用
|
||||
ConfigurableApplicationContext context = SpringApplication.run(GatewayServerApplication.class, args);
|
||||
|
||||
// 查看 Environment
|
||||
Environment environment = context.getEnvironment();
|
||||
System.out.println(environment);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 在 Nacos 配置发生变化时,Spring Cloud Alibaba Nacos Config 内置的监听器,会监听到配置刷新,最终触发 Gateway 的路由信息刷新。
|
||||
*
|
||||
* 参见 https://www.iocoder.cn/Spring-Cloud/Spring-Cloud-Gateway/?yudao 博客的「6. 基于配置中心 Nacos 实现动态路由」小节
|
||||
*
|
||||
* 使用方式:在 Nacos 修改 DataId 为 gateway-server.yaml 的配置,修改 spring.cloud.gateway.routes 配置项
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
package cn.iocoder.yudao.gateway.route.dynamic;
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 占位符
|
||||
*/
|
||||
package cn.iocoder.yudao.gateway.route;
|
||||
Reference in New Issue
Block a user