diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java index 19ec45d4d74..0ba34aa6444 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java @@ -39,6 +39,7 @@ import com.alibaba.nacos.common.utils.ConvertUtils; import com.alibaba.nacos.common.utils.StringUtils; +import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -151,9 +152,13 @@ private void initLogName(Properties properties) { } private void initCacheDir() { - cacheDir = System.getProperty("com.alibaba.nacos.naming.cache.dir"); - if (StringUtils.isEmpty(cacheDir)) { - cacheDir = System.getProperty("user.home") + "/nacos/naming/" + namespace; + String jmSnapshotPath = System.getProperty("JM.SNAPSHOT.PATH"); + if (!StringUtils.isBlank(jmSnapshotPath)) { + cacheDir = jmSnapshotPath + File.separator + "nacos" + File.separator + "naming" + + File.separator + namespace; + } else { + cacheDir = System.getProperty("user.home") + File.separator + "nacos" + File.separator + "naming" + + File.separator + namespace; } }