diff --git a/.gitignore b/.gitignore index e02b722f5..942b16d37 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # Compiled class file *.class +*.classpath +*.factorypath # Log file *.log diff --git a/spring-cloud-alibaba-nacos-discovery/src/main/java/org/springframework/cloud/alibaba/nacos/NacosDiscoveryClient.java b/spring-cloud-alibaba-nacos-discovery/src/main/java/org/springframework/cloud/alibaba/nacos/NacosDiscoveryClient.java index 1d22cd67d..4ad0e2e04 100644 --- a/spring-cloud-alibaba-nacos-discovery/src/main/java/org/springframework/cloud/alibaba/nacos/NacosDiscoveryClient.java +++ b/spring-cloud-alibaba-nacos-discovery/src/main/java/org/springframework/cloud/alibaba/nacos/NacosDiscoveryClient.java @@ -24,12 +24,12 @@ import org.springframework.cloud.client.discovery.DiscoveryClient; import java.util.*; -import com.alibaba.nacos.api.naming.NamingService; import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.api.naming.pojo.ListView; /** * @author xiaojing + * @author renhaojun */ public class NacosDiscoveryClient implements DiscoveryClient { @@ -98,8 +98,4 @@ public class NacosDiscoveryClient implements DiscoveryClient { return Collections.emptyList(); } } - - public NamingService getNamingService() { - return discoveryProperties.namingServiceInstance(); - } } diff --git a/spring-cloud-alibaba-nacos-discovery/src/main/java/org/springframework/cloud/alibaba/nacos/ribbon/NacosServerList.java b/spring-cloud-alibaba-nacos-discovery/src/main/java/org/springframework/cloud/alibaba/nacos/ribbon/NacosServerList.java index 261456622..ac33d6fd3 100644 --- a/spring-cloud-alibaba-nacos-discovery/src/main/java/org/springframework/cloud/alibaba/nacos/ribbon/NacosServerList.java +++ b/spring-cloud-alibaba-nacos-discovery/src/main/java/org/springframework/cloud/alibaba/nacos/ribbon/NacosServerList.java @@ -19,7 +19,7 @@ package org.springframework.cloud.alibaba.nacos.ribbon; import com.netflix.client.config.IClientConfig; import com.netflix.loadbalancer.AbstractServerList; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.alibaba.nacos.NacosDiscoveryClient; +import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties; import java.util.ArrayList; import java.util.List; @@ -28,11 +28,12 @@ import com.alibaba.nacos.api.naming.pojo.Instance; /** * @author xiaojing + * @author renhaojun */ public class NacosServerList extends AbstractServerList { @Autowired - private NacosDiscoveryClient discoveryClient; + private NacosDiscoveryProperties discoveryProperties; private String serviceId; @@ -55,7 +56,7 @@ public class NacosServerList extends AbstractServerList { private List getServers() { try { - List instances = discoveryClient.getNamingService() + List instances = discoveryProperties.namingServiceInstance() .getAllInstances(serviceId); return instancesToServerList(instances); }