Skip to content

Commit

Permalink
Fix #3314, set default nacos server address when `spring.config.impor…
Browse files Browse the repository at this point in the history
…t` enabled. (#3508)

* fix #3314, set default nacos server address when config.import enabled.
  • Loading branch information
chickenlj authored Jan 3, 2024
1 parent 7e18392 commit 35f83e3
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public class NacosConfigProperties {
*/
public static final String DEFAULT_NAMESPACE = "public";

/**
* Nacos default server and port.
*/
public static final String DEFAULT_ADDRESS = "127.0.0.1:8848";

private static final Pattern PATTERN = Pattern.compile("-(\\w)");

private static final Logger log = LoggerFactory
Expand Down Expand Up @@ -452,7 +457,7 @@ public void setRefreshEnabled(boolean refreshEnabled) {
public String getSharedDataids() {
return null == getSharedConfigs() ? null
: getSharedConfigs().stream().map(Config::getDataId)
.collect(Collectors.joining(COMMAS));
.collect(Collectors.joining(COMMAS));
}

/**
Expand Down Expand Up @@ -482,7 +487,7 @@ public void setSharedDataids(String sharedDataids) {
public String getRefreshableDataids() {
return null == getSharedConfigs() ? null
: getSharedConfigs().stream().filter(Config::isRefresh)
.map(Config::getDataId).collect(Collectors.joining(COMMAS));
.map(Config::getDataId).collect(Collectors.joining(COMMAS));
}

/**
Expand Down Expand Up @@ -561,7 +566,7 @@ public Properties getConfigServiceProperties() {
*/
public Properties assembleConfigServiceProperties() {
Properties properties = new Properties();
properties.put(SERVER_ADDR, Objects.toString(this.serverAddr, ""));
properties.put(SERVER_ADDR, Objects.toString(this.serverAddr, DEFAULT_ADDRESS));
properties.put(USERNAME, Objects.toString(this.username, ""));
properties.put(PASSWORD, Objects.toString(this.password, ""));
properties.put(ENCODE, Objects.toString(this.encode, ""));
Expand Down

0 comments on commit 35f83e3

Please sign in to comment.