mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
upgrade nacos client version
This commit is contained in:
@@ -47,15 +47,16 @@ import static com.alibaba.nacos.api.PropertyKeyConst.ACCESS_KEY;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.CLUSTER_NAME;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.CONFIG_RETRY_TIME;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.CONTEXT_PATH;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.ENABLE_REMOTE_SYNC_CONFIG;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.ENCODE;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT_PORT;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.MAX_RETRY;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.PASSWORD;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.USERNAME;
|
||||
|
||||
/**
|
||||
* Nacos properties.
|
||||
@@ -107,6 +108,14 @@ public class NacosConfigProperties {
|
||||
}
|
||||
this.setServerAddr(serverAddr);
|
||||
}
|
||||
if (StringUtils.isEmpty(this.getUsername())) {
|
||||
this.setUsername(
|
||||
environment.resolvePlaceholders("${spring.cloud.nacos.username:}"));
|
||||
}
|
||||
if (StringUtils.isEmpty(this.getPassword())) {
|
||||
this.setPassword(
|
||||
environment.resolvePlaceholders("${spring.cloud.nacos.password:}"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,6 +123,16 @@ public class NacosConfigProperties {
|
||||
*/
|
||||
private String serverAddr;
|
||||
|
||||
/**
|
||||
* the nacos authentication username.
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* the nacos authentication password.
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* encode for nacos config content.
|
||||
*/
|
||||
@@ -226,6 +245,22 @@ public class NacosConfigProperties {
|
||||
this.serverAddr = serverAddr;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
@@ -509,11 +544,12 @@ public class NacosConfigProperties {
|
||||
public Properties assembleConfigServiceProperties() {
|
||||
Properties properties = new Properties();
|
||||
properties.put(SERVER_ADDR, Objects.toString(this.serverAddr, ""));
|
||||
properties.put(USERNAME, Objects.toString(this.username, ""));
|
||||
properties.put(PASSWORD, Objects.toString(this.password, ""));
|
||||
properties.put(ENCODE, Objects.toString(this.encode, ""));
|
||||
properties.put(NAMESPACE, Objects.toString(this.namespace, ""));
|
||||
properties.put(ACCESS_KEY, Objects.toString(this.accessKey, ""));
|
||||
properties.put(SECRET_KEY, Objects.toString(this.secretKey, ""));
|
||||
properties.put(CONTEXT_PATH, Objects.toString(this.contextPath, ""));
|
||||
properties.put(CLUSTER_NAME, Objects.toString(this.clusterName, ""));
|
||||
properties.put(MAX_RETRY, Objects.toString(this.maxRetry, ""));
|
||||
properties.put(CONFIG_LONG_POLL_TIMEOUT,
|
||||
|
@@ -67,6 +67,28 @@
|
||||
"type": "java.lang.Boolean",
|
||||
"defaultValue": true,
|
||||
"description": "enable nacos config or not."
|
||||
},
|
||||
{
|
||||
"name": "spring.cloud.nacos.config.username",
|
||||
"type": "java.lang.String",
|
||||
"defaultValue": "${spring.cloud.nacos.username}",
|
||||
"description": "nacos config service's userName to authenticate."
|
||||
},
|
||||
{
|
||||
"name": "spring.cloud.nacos.config.password",
|
||||
"type": "java.lang.String",
|
||||
"defaultValue": "${spring.cloud.nacos.password}",
|
||||
"description": "nacos config service's password to authenticate."
|
||||
},
|
||||
{
|
||||
"name": "spring.cloud.nacos.username",
|
||||
"type": "java.lang.String",
|
||||
"description": "nacos userName to authenticate."
|
||||
},
|
||||
{
|
||||
"name": "spring.cloud.nacos.password",
|
||||
"type": "java.lang.String",
|
||||
"description": "nacos password to authenticate."
|
||||
}
|
||||
]
|
||||
}
|
@@ -54,8 +54,10 @@ import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT_PORT;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.NAMING_LOAD_CACHE_AT_START;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.PASSWORD;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.USERNAME;
|
||||
|
||||
/**
|
||||
* @author dungu.zpf
|
||||
@@ -82,6 +84,16 @@ public class NacosDiscoveryProperties {
|
||||
*/
|
||||
private String serverAddr;
|
||||
|
||||
/**
|
||||
* the nacos authentication username.
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* the nacos authentication password.
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* the domain name of a service, through which the server address can be dynamically
|
||||
* obtained.
|
||||
@@ -419,6 +431,22 @@ public class NacosDiscoveryProperties {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NacosDiscoveryProperties{" + "serverAddr='" + serverAddr + '\''
|
||||
@@ -474,6 +502,12 @@ public class NacosDiscoveryProperties {
|
||||
this.setGroup(
|
||||
env.resolvePlaceholders("${spring.cloud.nacos.discovery.group:}"));
|
||||
}
|
||||
if (StringUtils.isEmpty(this.getUsername())) {
|
||||
this.setUsername(env.resolvePlaceholders("${spring.cloud.nacos.username:}"));
|
||||
}
|
||||
if (StringUtils.isEmpty(this.getPassword())) {
|
||||
this.setPassword(env.resolvePlaceholders("${spring.cloud.nacos.password:}"));
|
||||
}
|
||||
}
|
||||
|
||||
public NamingService namingServiceInstance() {
|
||||
@@ -513,6 +547,8 @@ public class NacosDiscoveryProperties {
|
||||
private Properties getNacosProperties() {
|
||||
Properties properties = new Properties();
|
||||
properties.put(SERVER_ADDR, serverAddr);
|
||||
properties.put(USERNAME, Objects.toString(username,""));
|
||||
properties.put(PASSWORD, Objects.toString(password,""));
|
||||
properties.put(NAMESPACE, namespace);
|
||||
properties.put(UtilAndComs.NACOS_NAMING_LOG_NAME, logName);
|
||||
|
||||
|
@@ -34,5 +34,27 @@
|
||||
"type": "java.lang.Boolean",
|
||||
"defaultValue": "true",
|
||||
"description": "enable nacos discovery watch or not ."
|
||||
},
|
||||
{
|
||||
"name": "spring.cloud.nacos.discovery.username",
|
||||
"type": "java.lang.String",
|
||||
"defaultValue": "${spring.cloud.nacos.username}",
|
||||
"description": "nacos discovery service's username to authenticate."
|
||||
},
|
||||
{
|
||||
"name": "spring.cloud.nacos.discovery.password",
|
||||
"type": "java.lang.String",
|
||||
"defaultValue": "${spring.cloud.nacos.password}",
|
||||
"description": "nacos discovery service's password to authenticate."
|
||||
},
|
||||
{
|
||||
"name": "spring.cloud.nacos.username",
|
||||
"type": "java.lang.String",
|
||||
"description": "nacos userName to authenticate."
|
||||
},
|
||||
{
|
||||
"name": "spring.cloud.nacos.password",
|
||||
"type": "java.lang.String",
|
||||
"description": "nacos password to authenticate."
|
||||
}
|
||||
]}
|
||||
|
Reference in New Issue
Block a user