Open liudaac opened 1 year ago
NacosServiceMapping的初始化逻辑注入Url为metadataUrl,参考代码ConfigServer.getServiceMapping(ServiceDiscovery serviceDiscovery, InstanceRegistryCache instanceRegistryCache) 而目前按照Dubbo的处理逻辑,metadataUrl的group默认值为dubbo、registryUrl的group默认值为DEFAULT_GROUP,即存在metadataUrl与registryUrl不一致的情况,此时NacosServiceMapping使用metadataUrl初始化则导致getAllServiceNames()结果为空,现象为管理界面服务列表为空,此处应该修改为使用registryUrl进行初始化,才能使服务列表正常获取和显示,参考如下
@Bean @DependsOn("dubboRegistry") ServiceMapping getServiceMapping(ServiceDiscovery serviceDiscovery, InstanceRegistryCache instanceRegistryCache) { ServiceMapping serviceMapping = new NoOpServiceMapping(); if (registryUrl == null) { return serviceMapping; } MappingListener mappingListener = new AdminMappingListener(serviceDiscovery, instanceRegistryCache); serviceMapping = ExtensionLoader.getExtensionLoader(ServiceMapping.class).getExtension(registryUrl.getProtocol()); serviceMapping.addMappingListener(mappingListener); serviceMapping.init(registryUrl); return serviceMapping; }
Environment
Steps to reproduce this issue
NacosServiceMapping的初始化逻辑注入Url为metadataUrl,参考代码ConfigServer.getServiceMapping(ServiceDiscovery serviceDiscovery, InstanceRegistryCache instanceRegistryCache) 而目前按照Dubbo的处理逻辑,metadataUrl的group默认值为dubbo、registryUrl的group默认值为DEFAULT_GROUP,即存在metadataUrl与registryUrl不一致的情况,此时NacosServiceMapping使用metadataUrl初始化则导致getAllServiceNames()结果为空,现象为管理界面服务列表为空,此处应该修改为使用registryUrl进行初始化,才能使服务列表正常获取和显示,参考如下