提交 a674340c 编写于 作者: JEECG低代码平台's avatar JEECG低代码平台

微服务模式部署下,nacos的账户密码如果不使用默认提供的nacos/nacos,会导致gateway读取路由信息失败 #2375

上级 cbd8890c
...@@ -37,6 +37,10 @@ public class GatewayRoutersConfiguration { ...@@ -37,6 +37,10 @@ public class GatewayRoutersConfiguration {
public static String ROUTE_GROUP; public static String ROUTE_GROUP;
public static String USERNAME;
public static String PASSWORD;
/** /**
* 路由配置文件数据获取方式yml,nacos,database * 路由配置文件数据获取方式yml,nacos,database
*/ */
...@@ -63,8 +67,15 @@ public class GatewayRoutersConfiguration { ...@@ -63,8 +67,15 @@ public class GatewayRoutersConfiguration {
} }
@Value("${jeecg.route.config.data-type}") @Value("${jeecg.route.config.data-type}")
public void setDataType(String dataType) { public void setDataType(String dataType) { DATA_TYPE = 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 { ...@@ -79,6 +90,11 @@ public class GatewayRoutersConfiguration {
} }
/**
* 映射接口文档默认地址(通过9999端口直接访问)
* @param indexHtml
* @return
*/
@Bean @Bean
public RouterFunction<ServerResponse> indexRouter(@Value("classpath:/META-INF/resources/doc.html") final org.springframework.core.io.Resource indexHtml) { public RouterFunction<ServerResponse> 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)); return route(GET("/"), request -> ok().contentType(MediaType.TEXT_HTML).syncBody(indexHtml));
......
...@@ -299,6 +299,8 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware { ...@@ -299,6 +299,8 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverAddr", GatewayRoutersConfiguration.SERVER_ADDR); properties.setProperty("serverAddr", GatewayRoutersConfiguration.SERVER_ADDR);
properties.setProperty("namespace", GatewayRoutersConfiguration.NAMESPACE); properties.setProperty("namespace", GatewayRoutersConfiguration.NAMESPACE);
properties.setProperty("username",GatewayRoutersConfiguration.USERNAME);
properties.setProperty("password",GatewayRoutersConfiguration.PASSWORD);
return configService = NacosFactory.createConfigService(properties); return configService = NacosFactory.createConfigService(properties);
} catch (Exception e) { } catch (Exception e) {
log.error("创建ConfigService异常", e); log.error("创建ConfigService异常", e);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册