Skip to content

Commit

Permalink
update: nacos-config & nacos-discovery 增加contextPath配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizzercn committed May 12, 2023
1 parent a0cd1fc commit 7f033a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public class NacosConfigureLoader {
@PropDoc(value = "Nacos 密码", defaultValue = "")
public static final String NACOS_PASSWORD = NACOS_PRE + "password";

@PropDoc(value = "Nacos contextPath", defaultValue = "")
public static final String NACOS_CONTEXTPATH = NACOS_PRE + "contextPath";

@Inject
protected AppContext appContext;

Expand Down Expand Up @@ -220,7 +223,7 @@ public Properties getNacosConfigProperties() {
properties.put(NAMESPACE, conf.get(NACOS_NAMESPACE, ""));
properties.put(ACCESS_KEY, conf.get(NACOS_ACCESS_KEY, ""));
properties.put(SECRET_KEY, conf.get(NACOS_SECRET_KEY, ""));
properties.put(CONTEXT_PATH, conf.get(NACOS_CONTEXT_PATH, ""));
properties.put(CONTEXT_PATH, conf.get(NACOS_CONTEXT_PATH, conf.get(NACOS_CONTEXTPATH, "/nacos")));
properties.put(CLUSTER_NAME, conf.get(NACOS_CLUSTER_NAME, ""));
properties.put(MAX_RETRY, conf.get(NACOS_MAX_RETRY, ""));
properties.put(CONFIG_LONG_POLL_TIMEOUT, conf.get(NACOS_CONFIG_LONG_POLL_TIMEOUT, ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class NacosDiscoveryLoader implements ServerFace, NbAppEventListener {
@PropDoc(value = "Nacos SecretKey", defaultValue = "")
public static final String NACOS_SECRET_KEY = NACOS_PRE + "secret-key";

@PropDoc(value = "Nacos ContextPath", defaultValue = "")
public static final String NACOS_CONTEXT_PATH = NACOS_PRE + "context-path";

@PropDoc(value = "Nacos 集群名称", defaultValue = "", need = true)
public static final String NACOS_CLUSTER_NAME = NACOS_PRE + "cluster-name";

Expand Down Expand Up @@ -100,6 +103,9 @@ public class NacosDiscoveryLoader implements ServerFace, NbAppEventListener {
@PropDoc(value = "Nacos 密码", defaultValue = "")
public static final String NACOS_PASSWORD = NACOS_PRE + "password";

@PropDoc(value = "Nacos contextPath", defaultValue = "")
public static final String NACOS_CONTEXTPATH = NACOS_PRE + "contextPath";

@Inject
protected AppContext appContext;

Expand Down Expand Up @@ -157,7 +163,7 @@ public void afterAppStated(NbApp app) {
for (String key : metaDataMap.keySet()) {
instance.addMetadata(key, metaDataMap.getString(key));
}
if(conf.getBoolean(NACOS_NAMING_META_DATA_START_TIME, true)) {
if (conf.getBoolean(NACOS_NAMING_META_DATA_START_TIME, true)) {
instance.addMetadata("startTime", Times.getNowSDT());
}
namingService.registerInstance(serviceName, groupName, instance);
Expand Down Expand Up @@ -224,6 +230,7 @@ public Properties getNacosDiscoveryProperties() {
properties.put(NAMING_LOAD_CACHE_AT_START, conf.get(NACOS_NAMING_LOAD_CACHE_AT_START, "false"));
properties.put(USERNAME, conf.get(NACOS_USERNAME, ""));
properties.put(PASSWORD, conf.get(NACOS_PASSWORD, ""));
properties.put(CONTEXT_PATH, conf.get(NACOS_CONTEXT_PATH, conf.get(NACOS_CONTEXTPATH, "/nacos")));

return properties;
}
Expand Down

0 comments on commit 7f033a5

Please sign in to comment.