mirror of https://github.com/jeecgboot/jeecg-boot
微服务模式部署下,nacos的账户密码如果不使用默认提供的nacos/nacos,会导致gateway读取路由信息失败 #2375
parent
cbd8890cb3
commit
a674340c5e
|
@ -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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 映射接口文档默认地址(通过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 {
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue