From a674340c5eccb5f4e7b97e8fdd568fc5c304e153 Mon Sep 17 00:00:00 2001 From: zhangdaiscott Date: Sun, 28 Mar 2021 19:45:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E6=9C=8D=E5=8A=A1=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E4=B8=8B=EF=BC=8Cnacos=E7=9A=84=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E5=AF=86=E7=A0=81=E5=A6=82=E6=9E=9C=E4=B8=8D=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E9=BB=98=E8=AE=A4=E6=8F=90=E4=BE=9B=E7=9A=84nacos/nac?= =?UTF-8?q?os=EF=BC=8C=E4=BC=9A=E5=AF=BC=E8=87=B4gateway=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E4=BF=A1=E6=81=AF=E5=A4=B1=E8=B4=A5=20#2375?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/GatewayRoutersConfiguration.java | 20 +++++++++++++++++-- .../org/jeecg/loader/DynamicRouteLoader.java | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/GatewayRoutersConfiguration.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/GatewayRoutersConfiguration.java index a3196e42..a65bd4f7 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/GatewayRoutersConfiguration.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/config/GatewayRoutersConfiguration.java @@ -37,6 +37,10 @@ public class GatewayRoutersConfiguration { public static String ROUTE_GROUP; + public static String USERNAME; + + public static String PASSWORD; + /** * 路由配置文件数据获取方式yml,nacos,database */ @@ -63,8 +67,15 @@ public class GatewayRoutersConfiguration { } @Value("${jeecg.route.config.data-type}") - public void setDataType(String dataType) { - DATA_TYPE = dataType; + public void setDataType(String dataType) { DATA_TYPE = dataType; } + + @Value("${spring.cloud.nacos.config.username}") + public void setUsername(String username) { + USERNAME = username; + } + @Value("${spring.cloud.nacos.config.password}") + public void setPassword(String password) { + PASSWORD = password; } @@ -79,6 +90,11 @@ public class GatewayRoutersConfiguration { } + /** + * 映射接口文档默认地址(通过9999端口直接访问) + * @param indexHtml + * @return + */ @Bean public RouterFunction indexRouter(@Value("classpath:/META-INF/resources/doc.html") final org.springframework.core.io.Resource indexHtml) { return route(GET("/"), request -> ok().contentType(MediaType.TEXT_HTML).syncBody(indexHtml)); diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/DynamicRouteLoader.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/DynamicRouteLoader.java index e6cc048f..d3d3420d 100644 --- a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/DynamicRouteLoader.java +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-gateway/src/main/java/org/jeecg/loader/DynamicRouteLoader.java @@ -299,6 +299,8 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware { Properties properties = new Properties(); properties.setProperty("serverAddr", GatewayRoutersConfiguration.SERVER_ADDR); properties.setProperty("namespace", GatewayRoutersConfiguration.NAMESPACE); + properties.setProperty("username",GatewayRoutersConfiguration.USERNAME); + properties.setProperty("password",GatewayRoutersConfiguration.PASSWORD); return configService = NacosFactory.createConfigService(properties); } catch (Exception e) { log.error("创建ConfigService异常", e); -- GitLab