mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
refactor(nacos): Modify nacos service caching mechanism
This commit is contained in:
@@ -19,6 +19,7 @@ package com.alibaba.cloud.nacos.client;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosConfigManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.bootstrap.config.PropertySourceLocator;
|
||||
@@ -54,14 +55,17 @@ public class NacosPropertySourceLocator implements PropertySourceLocator {
|
||||
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
|
||||
public NacosPropertySourceLocator(NacosConfigProperties nacosConfigProperties) {
|
||||
private NacosConfigManager nacosConfigManager;
|
||||
|
||||
public NacosPropertySourceLocator(NacosConfigManager nacosConfigManager, NacosConfigProperties nacosConfigProperties) {
|
||||
this.nacosConfigManager = nacosConfigManager;
|
||||
this.nacosConfigProperties = nacosConfigProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertySource<?> locate(Environment env) {
|
||||
|
||||
ConfigService configService = nacosConfigProperties.configServiceInstance();
|
||||
ConfigService configService = nacosConfigManager.getConfigService();
|
||||
|
||||
if (null == configService) {
|
||||
log.warn("no instance of config service found, can't load config from nacos");
|
||||
|
Reference in New Issue
Block a user