1
0
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:
yuhuangbin
2020-03-06 22:44:27 +08:00
parent b2d1e430c3
commit 756c82ba1e
15 changed files with 150 additions and 4 deletions

View File

@@ -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);

View File

@@ -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."
}
]}