Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持修改context-path #290

Merged
merged 1 commit into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public Properties buildGlobalNacosProperties() {
nacosConfigProperties.getConfigLongPollTimeout(),
nacosConfigProperties.getConfigRetryTime(),
nacosConfigProperties.getMaxRetry(),
nacosConfigProperties.getContextPath(),
nacosConfigProperties.isEnableRemoteSyncConfig(),
nacosConfigProperties.getUsername(), nacosConfigProperties.getPassword());
}
Expand All @@ -105,7 +106,7 @@ private Properties buildSubNacosProperties(Properties globalProperties,
config.getServerAddr(), config.getNamespace(), config.getEndpoint(),
config.getSecretKey(), config.getAccessKey(), config.getRamRoleName(),
config.getConfigLongPollTimeout(), config.getConfigRetryTime(),
config.getMaxRetry(), config.isEnableRemoteSyncConfig(),
config.getMaxRetry(),null, config.isEnableRemoteSyncConfig(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null能否换成默认值?

Copy link
Contributor Author

@slatonwu slatonwu Jun 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是扩展配置的构建,为null时会默认继承主配置里面的配置项,如果使用默认配置的话会和主配置不一致。当主配置项没有配置context-path时,主配置的context-path就是默认值,扩展配置会同步继承默认配置,所以这个地方是null就可以了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spring-cloud-alibaba 中context-path配置是可以修改的,希望修改可以被接受

config.getUsername(), config.getPassword());
NacosPropertiesBuilder.merge(sub, globalProperties);
return sub;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class NacosPropertiesBuilder {
public static Properties buildNacosProperties(Environment environment,
String serverAddr, String namespaceId, String endpoint, String secretKey,
String accessKey, String ramRoleName, String configLongPollTimeout,
String configRetryTimeout, String maxRetry, boolean enableRemoteSyncConfig,
String configRetryTimeout, String maxRetry,String contextPath, boolean enableRemoteSyncConfig,
String username, String password) {
Properties properties = new Properties();
processPropertiesData(properties,environment,serverAddr,PropertyKeyConst.SERVER_ADDR);
Expand All @@ -45,6 +45,7 @@ public static Properties buildNacosProperties(Environment environment,
processPropertiesData(properties,environment,ramRoleName,PropertyKeyConst.RAM_ROLE_NAME);
processPropertiesData(properties,environment,configLongPollTimeout,PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT);
processPropertiesData(properties,environment,configRetryTimeout,PropertyKeyConst.CONFIG_RETRY_TIME);
processPropertiesData(properties,environment,contextPath,PropertyKeyConst.CONTEXT_PATH);
processPropertiesData(properties,environment,maxRetry,PropertyKeyConst.MAX_RETRY);
processPropertiesData(properties,environment,username,PropertyKeyConst.USERNAME);
processPropertiesData(properties,environment,password,PropertyKeyConst.PASSWORD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void buildNacosProperties() {
String username = "nacos";
String password = "password";
Properties properties = NacosPropertiesBuilder.buildNacosProperties(environment, serverAddr, namespaceId, secretKey,
"ak", ramRoleName, configLongPollTimeout, configRetryTimeout, maxRetry, enableRemoteSyncConfig, true,
"ak", ramRoleName, configLongPollTimeout, configRetryTimeout, maxRetry, null,enableRemoteSyncConfig, true,
username, password);
Assert.assertEquals(properties.size(), 12);

Expand Down