{"id":1136,"date":"2022-12-15T19:57:35","date_gmt":"2022-12-16T03:57:35","guid":{"rendered":"https:\/\/ligai.cn\/blog\/?p=1136"},"modified":"2022-12-15T19:57:35","modified_gmt":"2022-12-16T03:57:35","slug":"%e6%8a%80%e6%9c%af%e5%88%86%e4%ba%ab-%e5%a4%9a%e4%b8%aa%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%a6%82%e4%bd%95%e8%b7%a8%e5%91%bd%e5%90%8d%e7%a9%ba%e9%97%b4%ef%bc%8c%e8%ae%bf%e9%97%ae%e5%85%ac%e5%85%b1","status":"publish","type":"post","link":"https:\/\/ligai.cn\/blog\/sharing\/1136.html","title":{"rendered":"\u6280\u672f\u5206\u4eab | \u591a\u4e2a\u670d\u52a1\u5668\u5982\u4f55\u8de8\u547d\u540d\u7a7a\u95f4\uff0c\u8bbf\u95ee\u516c\u5171\u670d\u52a1\uff1f"},"content":{"rendered":"\n<h2><strong>\u4e00\u3001\u95ee\u9898\u80cc\u666f<\/strong><\/h2>\n\n\n\n<p>\u5728\u5f00\u53d1\u67d0\u4e2a\u516c\u5171\u5e94\u7528\u65f6\uff0c\u7b14\u8005\u53d1\u73b0\u8be5\u516c\u5171\u5e94\u7528\u7684\u6570\u636e\u662f\u6240\u6709\u6d4b\u8bd5\u73af\u5883\uff08\u5047\u8bbe\u5b58\u5728 dev\/dev2\/dev3\uff09\u901a\u7528\u7684\u3002<\/p>\n\n\n\n<p>\u8fd9\u5c31\u610f\u5473\u7740\u53ea\u9700\u90e8\u7f72\u4e00\u4e2a\u5e94\u7528\uff0c\u5c31\u80fd\u6ee1\u8db3\u6240\u6709\u6d4b\u8bd5\u73af\u5883\u7684\u9700\u6c42\uff1b\u4e5f\u610f\u5473\u7740\u6240\u6709\u6d4b\u8bd5\u73af\u5883\u90fd\u9700\u8981\u8c03\u7528\u8be5\u516c\u5171\u5e94\u7528\uff0c\u800c\u4e0d\u540c\u6d4b\u8bd5\u73af\u5883\u7684\u5e94\u7528\u6ce8\u518c\u5728\u4e0d\u540c\u7684 Nacos \u547d\u540d\u7a7a\u95f4\u3002<\/p>\n\n\n\n<h2><strong>\u4e8c\u3001\u4e24\u79cd\u89e3\u51b3\u65b9\u6848<\/strong><\/h2>\n\n\n\n<p>\u5982\u679c\u6240\u6709\u6d4b\u8bd5\u73af\u5883\u90fd\u9700\u8981\u8c03\u7528\u8be5\u516c\u5171\u5e94\u7528\uff0c\u6709\u4e24\u79cd\u53ef\u884c\u7684\u65b9\u6848\u3002<strong>\u7b2c\u4e00\u79cd\uff0c\u5c06\u8be5\u516c\u5171\u670d\u52a1\u540c\u65f6\u6ce8\u518c\u5230\u4e0d\u540c\u7684\u6d4b\u8bd5\u73af\u5883\u6240\u5bf9\u5e94\u7684\u547d\u540d\u7a7a\u95f4\u4e2d\u3002<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"347\" src=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/1-1024x347.png\" alt=\"\" class=\"wp-image-1137\" srcset=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/1-1024x347.png 1024w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/1-300x102.png 300w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/1-768x261.png 768w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/1.png 1070w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>\u7b2c\u4e8c\u79cd\uff0c\u5c06\u516c\u5171\u5e94\u7528\u6ce8\u518c\u5230\u5355\u72ec\u7684\u547d\u540d\u7a7a\u95f4\uff0c\u4e0d\u540c\u7684\u6d4b\u8bd5\u73af\u5883\u80fd\u591f\u8de8\u547d\u540d\u7a7a\u95f4\u8bbf\u95ee\u8be5\u5e94\u7528\u3002<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"538\" src=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/2-1024x538.png\" alt=\"\" class=\"wp-image-1138\" srcset=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/2-1024x538.png 1024w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/2-300x158.png 300w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/2-768x403.png 768w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/2.png 1034w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2><strong>\u4e09\u3001\u8be6\u7ec6\u7684\u95ee\u9898\u89e3\u51b3\u8fc7\u7a0b<\/strong><\/h2>\n\n\n\n<p>\u5148\u884c\u4ea4\u4ee3\u7b14\u8005\u7684\u7248\u672c\u53f7\u914d\u7f6e\u3002Nacos \u5ba2\u6237\u7aef\u7248\u672c\u53f7\u4e3a<strong> <code>NACOS 1.4.1<\/code><\/strong>\uff1bJava \u9879\u76ee\u7684 Nacos \u7248\u672c\u53f7\u5982\u4e0b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"936\" height=\"496\" src=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/3.png\" alt=\"\" class=\"wp-image-1139\" srcset=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/3.png 936w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/3-300x159.png 300w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/3-768x407.png 768w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/figure>\n\n\n\n<p>\u6700\u521d\u60f3\u6cd5\u662f\u5c06\u8be5\u516c\u5171\u5e94\u7528\u540c\u65f6\u6ce8\u518c\u5230\u591a\u4e2a\u547d\u540d\u7a7a\u95f4\u4e0b\u3002\u5728\u67e5\u627e\u8d44\u6599\u7684\u8fc7\u7a0b\u4e2d\uff0c\u56e2\u961f\u6210\u5458\u5728 <code>GitHub<\/code> \u4e0a\u53d1\u73b0\u4e86\u4e00\u7bc7\u7c7b\u4f3c\u95ee\u9898\u7684\u535a\u5ba2\u5206\u4eab\uff1a<a href=\"https:\/\/github.com\/alibaba\/nacos\/issues\/1176\">Registration Center: Can services in different namespaces be called from each other? #1176<\/a>\u3002<\/p>\n\n\n\n<h3><strong>01 \u6ce8\u518c\u591a\u4e2a\u547d\u540d\u7a7a\u95f4<\/strong><\/h3>\n\n\n\n<p>\u4ece\u8be5\u535a\u5ba2\u4e2d\uff0c\u6211\u4eec\u770b\u5230\u5176\u4ed6\u7a0b\u5e8f\u5458\u670b\u53cb\u4e5f\u9047\u5230\u4e86\u7c7b\u4f3c\u7684\u516c\u5171\u670d\u52a1\u7684\u9700\u6c42\u3002\u5728\u672c\u7bc7\u6587\u7ae0\u4e2d\uff0c\u7b14\u8005\u5c06\u8fdb\u4e00\u6b65\u5206\u4eab\u5b9e\u73b0\u601d\u8def\u4ee5\u53ca\u793a\u4f8b\u4ee3\u7801\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"192\" src=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-1-1024x192.png\" alt=\"\" class=\"wp-image-1140\" srcset=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-1-1024x192.png 1024w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-1-300x56.png 300w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-1-768x144.png 768w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-1.png 1240w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"823\" src=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-2-1024x823.png\" alt=\"\" class=\"wp-image-1141\" srcset=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-2-1024x823.png 1024w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-2-300x241.png 300w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-2-768x617.png 768w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-2.png 1240w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"437\" src=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-3-1024x437.png\" alt=\"\" class=\"wp-image-1142\" srcset=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-3-1024x437.png 1024w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-3-300x128.png 300w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-3-768x328.png 768w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/5-3.png 1240w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-style-default\"><p>\u8bf4\u660e\uff1a\u4ee5\u4e0b\u4ee3\u7801\u5185\u5bb9\u6765\u81ea\u7528\u6237 chuntaojun \u7684\u5206\u4eab\u3002<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>shareNamespace={namespaceId&#91;:group]},{namespaceId&#91;:group]} <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>@RunWith(SpringRunner.class)\n@SpringBootTest(classes = NamingApp.class, properties = {\"server.servlet.context-path=\/nacos\"},\n    webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)\npublic class SelectServiceInShareNamespace_ITCase {\n\n    private NamingService naming1;\n    private NamingService naming2;\n    @LocalServerPort\n    private int port;\n    @Before\n    public void init() throws Exception{\n        NamingBase.prepareServer(port);\n        if (naming1 == null) {\n            Properties properties = new Properties();\n            properties.setProperty(PropertyKeyConst.SERVER_ADDR, \"127.0.0.1\"+\":\"+port);\n            properties.setProperty(PropertyKeyConst.SHARE_NAMESPACE, \"57425802-3058-4507-9a73-3229b9f00a36\");\n            naming1 = NamingFactory.createNamingService(properties);\n\n            Properties properties2 = new Properties();\n            properties2.setProperty(PropertyKeyConst.SERVER_ADDR, \"127.0.0.1\"+\":\"+port);\n            properties2.setProperty(PropertyKeyConst.NAMESPACE, \"57425802-3058-4507-9a73-3229b9f00a36\");\n            naming2 = NamingFactory.createNamingService(properties2);\n        }\n        while (true) {\n            if (!\"UP\".equals(naming1.getServerStatus())) {\n                Thread.sleep(1000L);\n                continue;\n            }\n            break;\n        }\n    }\n\n    @Test\n    public void testSelectInstanceInShareNamespaceNoGroup() throws NacosException, InterruptedException {\n        String service1 = randomDomainName();\n        String service2 = randomDomainName();\n        naming1.registerInstance(service1, \"127.0.0.1\", 90);\n        naming2.registerInstance(service2, \"127.0.0.2\", 90);\n\n        Thread.sleep(1000);\n\n        List&lt;Instance&gt; instances = naming1.getAllInstances(service2);\n        Assert.assertEquals(1, instances.size());\n        Assert.assertEquals(service2, NamingUtils.getServiceName(instances.get(0).getServiceName()));\n    }\n\n    @Test\n    public void testSelectInstanceInShareNamespaceWithGroup() throws NacosException, InterruptedException {\n        String service1 = randomDomainName();\n        String service2 = randomDomainName();\n        naming2.registerInstance(service1, groupName, \"127.0.0.1\", 90);\n        naming3.registerInstance(service2, \"127.0.0.2\", 90);\n\n        Thread.sleep(1000);\n\n        List&lt;Instance&gt; instances = naming3.getAllInstances(service1);\n        Assert.assertEquals(1, instances.size());\n        Assert.assertEquals(service1, NamingUtils.getServiceName(instances.get(0).getServiceName()));\n        Assert.assertEquals(groupName, NamingUtils.getServiceName(NamingUtils.getGroupName(instances.get(0).getServiceName())));\n    }\n\n}<\/code><\/pre>\n\n\n\n<p>\u8fdb\u4e00\u6b65\u8003\u8651\u540e\u53d1\u73b0\u8be5\u89e3\u51b3\u65b9\u6848\u53ef\u80fd\u4e0d\u592a\u5951\u5408\u5f53\u524d\u9047\u5230\u7684\u95ee\u9898\u3002\u516c\u53f8\u76ee\u524d\u7684\u5f00\u53d1\u6d4b\u8bd5\u73af\u5883\u6709\u5f88\u591a\u4e2a\uff0c\u5e76\u4e14\u4e0d\u786e\u5b9a\u4ee5\u540e\u4f1a\u4e0d\u4f1a\u7ee7\u7eed\u589e\u52a0\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6bcf\u589e\u52a0\u4e00\u4e2a\u73af\u5883\uff0c\u90fd\u9700\u8981\u4fee\u6539\u4e00\u6b21\u516c\u5171\u670d\u52a1\u7684\u914d\u7f6e\uff0c\u5e76\u4e14\u91cd\u542f\u4e00\u6b21\u516c\u5171\u670d\u52a1\uff0c\u7740\u5b9e\u592a\u9ebb\u70e6\u4e86\u3002\u5012\u4e0d\u5982\u53cd\u5176\u9053\u800c\u884c\uff0c\u8ba9\u5176\u4ed6\u7684\u670d\u52a1\u5668\u5b9e\u73b0\u8de8\u547d\u540d\u7a7a\u95f4\u8bbf\u95ee\u516c\u5171\u670d\u52a1\u3002<\/p>\n\n\n\n<h3><strong>02 \u8de8\u547d\u540d\u7a7a\u95f4\u8bbf\u95ee<\/strong><\/h3>\n\n\n\n<p>\u9488\u5bf9\u5b9e\u9645\u95ee\u9898\u67e5\u627e\u8d44\u6599\u65f6\uff0c\u6211\u4eec\u627e\u5230\u4e86\u7c7b\u4f3c\u7684\u53c2\u8003\u5206\u4eab<a href=\"https:\/\/www.cnblogs.com\/changxy-codest\/p\/14632574.html\">\u300a\u91cd\u5199 Nacos \u670d\u52a1\u53d1\u73b0\u903b\u8f91\u52a8\u6001\u4fee\u6539\u8fdc\u7a0b\u670d\u52a1IP\u5730\u5740\u300b<\/a>\u3002<\/p>\n\n\n\n<p>\u8ddf\u7740\u535a\u5ba2\u601d\u8def\u770b\u4ee3\u7801\uff0c\u7b14\u8005\u4e86\u89e3\u5230<strong>\u670d\u52a1\u53d1\u73b0\u7684\u4e3b\u8981\u76f8\u5173\u7c7b\u662f <code>NacosNamingService<\/code>, <code>NacosDiscoveryProperties<\/code>, <code>NacosDiscoveryAutoConfiguration<\/code><\/strong>\u3002<\/p>\n\n\n\n<p>\u7136\u540e\uff0c\u7b14\u8005\u5c06\u535a\u5ba2\u7684\u793a\u4f8b\u4ee3\u7801\u590d\u5236\u8fc7\u6765\uff0c\u8bd5\u7740\u8fdb\u884c\u5982\u4e0b\u8c03\u8bd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Slf4j\n@Configuration\n@ConditionalOnNacosDiscoveryEnabled\n@ConditionalOnProperty(\n        name = {\"spring.profiles.active\"},\n        havingValue = \"dev\"\n)\n@AutoConfigureBefore({NacosDiscoveryClientAutoConfiguration.class})\npublic class DevEnvironmentNacosDiscoveryClient {\n\n    @Bean\n    @ConditionalOnMissingBean\n    public NacosDiscoveryProperties nacosProperties() {\n        return new DevEnvironmentNacosDiscoveryProperties();\n    }\n\n    static class DevEnvironmentNacosDiscoveryProperties extends NacosDiscoveryProperties {\n\n        private NamingService namingService;\n\n        @Override\n        public NamingService namingServiceInstance() {\n            if (null != this.namingService) {\n                return this.namingService;\n            } else {\n                Properties properties = new Properties();\n                properties.put(\"serverAddr\", super.getServerAddr());\n                properties.put(\"namespace\", super.getNamespace());\n                properties.put(\"com.alibaba.nacos.naming.log.filename\", super.getLogName());\n                if (super.getEndpoint().contains(\":\")) {\n                    int index = super.getEndpoint().indexOf(\":\");\n                    properties.put(\"endpoint\", super.getEndpoint().substring(0, index));\n                    properties.put(\"endpointPort\", super.getEndpoint().substring(index + 1));\n                } else {\n                    properties.put(\"endpoint\", super.getEndpoint());\n                }\n\n                properties.put(\"accessKey\", super.getAccessKey());\n                properties.put(\"secretKey\", super.getSecretKey());\n                properties.put(\"clusterName\", super.getClusterName());\n                properties.put(\"namingLoadCacheAtStart\", super.getNamingLoadCacheAtStart());\n\n                try {\n                    this.namingService = new DevEnvironmentNacosNamingService(properties);\n                } catch (Exception var3) {\n                    log.error(\"create naming service error!properties={},e=,\", this, var3);\n                    return null;\n                }\n\n                return this.namingService;\n            }\n        }\n\n    }\n\n    static class DevEnvironmentNacosNamingService extends NacosNamingService {\n\n        public DevEnvironmentNacosNamingService(Properties properties) {\n            super(properties);\n        }\n\n        @Override\n        public List&lt;Instance&gt; selectInstances(String serviceName, List&lt;String&gt; clusters, boolean healthy) throws NacosException {\n            List&lt;Instance&gt; instances = super.selectInstances(serviceName, clusters, healthy);\n            instances.stream().forEach(instance -&gt; instance.setIp(\"10.101.232.24\"));\n            return instances;\n        }\n    }\n\n}<\/code><\/pre>\n\n\n\n<p>\u8c03\u8bd5\u540e\u53d1\u73b0\u535a\u5ba2\u63d0\u4f9b\u7684\u4ee3\u7801\u5e76\u4e0d\u80fd\u6ee1\u8db3\u7b14\u8005\u7684\u9700\u6c42\uff0c\u8fd8\u5f97\u8fdb\u4e00\u6b65\u6df1\u5165\u63a2\u7d22\u3002<\/p>\n\n\n\n<p>\u4f46\u5e78\u8fd0\u7684\u662f\uff0c\u8c03\u8bd5\u8fc7\u7a0b\u53d1\u73b0<strong> Nacos \u670d\u52a1\u53d1\u73b0\u7684\u5173\u952e\u7c7b\u662f <code>com.alibaba.cloud.nacos.discovery.NacosServiceDiscovery<\/code>\uff0c\u5176\u4e2d\u7684\u5173\u952e\u65b9\u6cd5\u662f <code>getInstances()<\/code> \u548c <code>getServices()<\/code>\uff0c\u5373\u300c\u8fd4\u56de\u6307\u5b9a\u670d\u52a1 ID \u7684\u6240\u6709\u670d\u52a1\u5b9e\u4f8b\u300d\u548c\u300c\u83b7\u53d6\u6240\u6709\u670d\u52a1\u7684\u540d\u79f0\u300d<\/strong>\u3002<\/p>\n\n\n\n<p>\u4e5f\u5c31\u662f\u8bf4\uff0c<strong>\u5bf9 <code>getInstances()<\/code> \u65b9\u6cd5\u8fdb\u884c\u91cd\u5199\u80af\u5b9a\u80fd\u5b9e\u73b0\u672c\u6b21\u76ee\u6807\u2014\u2014\u8de8\u547d\u540d\u7a7a\u95f4\u8bbf\u95ee\u516c\u5171\u670d\u52a1<\/strong>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * Return all instances for the given service.\n * @param serviceId id of service\n * @return list of instances\n * @throws NacosException nacosException\n *\/\npublic List&lt;ServiceInstance&gt; getInstances(String serviceId) throws NacosException {\n        String group = discoveryProperties.getGroup();\n        List&lt;Instance&gt; instances = discoveryProperties.namingServiceInstance()\n                        .selectInstances(serviceId, group, true);\n        return hostToServiceInstanceList(instances, serviceId);\n}\n\n\/**\n * Return the names of all services.\n * @return list of service names\n * @throws NacosException nacosException\n *\/\npublic List&lt;String&gt; getServices() throws NacosException {\n        String group = discoveryProperties.getGroup();\n        ListView&lt;String&gt; services = discoveryProperties.namingServiceInstance()\n                        .getServicesOfServer(1, Integer.MAX_VALUE, group);\n        return services.getData();\n}<\/code><\/pre>\n\n\n\n<h3><strong>03 \u6700\u7ec8\u89e3\u51b3\u601d\u8def\u53ca\u4ee3\u7801\u793a\u4f8b<\/strong><\/h3>\n\n\n\n<p>\u5177\u4f53\u7684\u89e3\u51b3\u65b9\u6848\u601d\u8def\u5927\u81f4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-style-default\"><p><strong>1. \u751f\u6210\u4e00\u4e2a\u5171\u4eab\u914d\u7f6e\u7c7b<code>NacosShareProperties<\/code>\uff0c\u7528\u6765\u914d\u7f6e\u5171\u4eab\u516c\u5171\u670d\u52a1\u7684 <code>namespace<\/code> \u548c <code>group<\/code>\uff1b<\/strong><\/p><p><strong>2. \u91cd\u5199\u914d\u7f6e\u7c7b <code>NacosDiscoveryProperties<\/code> \uff08\u65b0\uff1a<code>NacosDiscoveryPropertiesV2<\/code>\uff09\uff0c\u5c06\u65b0\u589e\u7684\u5171\u4eab\u914d\u7f6e\u7c7b\u4f5c\u4e3a\u5c5e\u6027\u653e\u8fdb\u8be5\u914d\u7f6e\u7c7b\uff0c\u540e\u7eed\u4f1a\u7528\u5230\uff1b<\/strong><\/p><p><strong>3. \u91cd\u5199\u670d\u52a1\u53d1\u73b0\u7c7b <code>NacosServiceDiscovery<\/code> \uff08\u65b0\uff1a<code>NacosServiceDiscoveryV2<\/code>\uff09\uff0c\u8fd9\u662f\u6700\u5173\u952e\u7684\u903b\u8f91\uff1b<\/strong><\/p><p><strong>4. \u91cd\u5199\u81ea\u52a8\u914d\u7f6e\u7c7b <code>NacosDiscoveryAutoConfiguration<\/code>\uff0c\u5c06\u81ea\u5b9a\u4e49\u76f8\u5173\u7c7b\u6bd4 Nacos \u539f\u751f\u7c7b\u66f4\u65e9\u7684\u6ce8\u5165\u5bb9\u5668\u3002<\/strong><\/p><\/blockquote>\n\n\n\n<p>\u6700\u7ec8\u4ee3\u7801\u4e2d\u7528\u5230\u4e86\u4e00\u4e9b\u5de5\u5177\u7c7b\uff0c\u53ef\u4ee5\u81ea\u884c\u8865\u5145\u5b8c\u6574\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * &lt;pre&gt;\n *  @description: \u5171\u4eabnacos\u5c5e\u6027\n *  @author: rookie0peng\n *  @date: 2022\/8\/29 15:22\n *  &lt;\/pre&gt;\n *\/\n@Configuration\n@ConfigurationProperties(prefix = \"nacos.share\")\npublic class NacosShareProperties {\n\n    private final Map&lt;String, Set&lt;String&gt;&gt; NAMESPACE_TO_GROUP_NAME_MAP = new ConcurrentHashMap&lt;&gt;();\n\n    \/**\n     * \u5171\u4eabnacos\u5b9e\u4f53\u5217\u8868\n     *\/\n    private List&lt;NacosShareEntity&gt; entities;\n\n    public List&lt;NacosShareEntity&gt; getEntities() {\n        return entities;\n    }\n\n    public void setEntities(List&lt;NacosShareEntity&gt; entities) {\n        this.entities = entities;\n    }\n\n    public Map&lt;String, Set&lt;String&gt;&gt; getNamespaceGroupMap() {\n        safeStream(entities).filter(entity -&gt; nonNull(entity) &amp;&amp; nonNull(entity.getNamespace()))\n                .forEach(entity -&gt; {\n                    Set&lt;String&gt; groupNames = NAMESPACE_TO_GROUP_NAME_MAP.computeIfAbsent(entity.getNamespace(), k -&gt; new HashSet&lt;&gt;());\n                    if (nonNull(entity.getGroupNames()))\n                        groupNames.addAll(entity.getGroupNames());\n                });\n        return new HashMap&lt;&gt;(NAMESPACE_TO_GROUP_NAME_MAP);\n    }\n\n    @Override\n    public String toString() {\n        return \"NacosShareProperties{\" +\n                \"entities=\" + entities +\n                '}';\n    }\n\n    \/**\n     * \u5171\u4eabnacos\u5b9e\u4f53\n     *\/\n    public static final class NacosShareEntity {\n\n        \/**\n         * \u547d\u540d\u7a7a\u95f4\n         *\/\n        private String namespace;\n\n        \/**\n         * \u5206\u7ec4\n         *\/\n        private List&lt;String&gt; groupNames;\n\n        public String getNamespace() {\n            return namespace;\n        }\n\n        public void setNamespace(String namespace) {\n            this.namespace = namespace;\n        }\n\n        public List&lt;String&gt; getGroupNames() {\n            return groupNames;\n        }\n\n        public void setGroupNames(List&lt;String&gt; groupNames) {\n            this.groupNames = groupNames;\n        }\n\n        @Override\n        public String toString() {\n            return \"NacosShareEntity{\" +\n                    \"namespace='\" + namespace + '\\'' +\n                    \", groupNames=\" + groupNames +\n                    '}';\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @description: naocs\u670d\u52a1\u53d1\u73b0\u5c5e\u6027\u91cd\u5199\n * @author: rookie0peng\n * @date: 2022\/8\/30 1:19\n *\/\npublic class NacosDiscoveryPropertiesV2 extends NacosDiscoveryProperties {\n\n    private static final Logger log = LoggerFactory.getLogger(NacosDiscoveryPropertiesV2.class);\n\n    private final NacosShareProperties nacosShareProperties;\n\n    private static final Map&lt;String, NamingService&gt; NAMESPACE_TO_NAMING_SERVICE_MAP = new ConcurrentHashMap&lt;&gt;();\n\n    public NacosDiscoveryPropertiesV2(NacosShareProperties nacosShareProperties) {\n        super();\n        this.nacosShareProperties = nacosShareProperties;\n    }\n\n    public Map&lt;String, NamingService&gt; shareNamingServiceInstances() {\n        if (!NAMESPACE_TO_NAMING_SERVICE_MAP.isEmpty()) {\n            return new HashMap&lt;&gt;(NAMESPACE_TO_NAMING_SERVICE_MAP);\n        }\n        List&lt;NacosShareProperties.NacosShareEntity&gt; entities = Optional.ofNullable(nacosShareProperties)\n                .map(NacosShareProperties::getEntities).orElse(Collections.emptyList());\n        entities.stream().filter(entity -&gt; nonNull(entity) &amp;&amp; nonNull(entity.getNamespace()))\n                .filter(PredicateUtil.distinctByKey(NacosShareProperties.NacosShareEntity::getNamespace))\n                .forEach(entity -&gt; {\n                    try {\n                        NamingService namingService = NacosFactory.createNamingService(getNacosProperties(entity.getNamespace()));\n                        if (namingService != null) {\n                            NAMESPACE_TO_NAMING_SERVICE_MAP.put(entity.getNamespace(), namingService);\n                        }\n                    } catch (Exception e) {\n                        log.error(\"create naming service error! properties={}, e=\", this, e);\n                    }\n                });\n        return new HashMap&lt;&gt;(NAMESPACE_TO_NAMING_SERVICE_MAP);\n    }\n\n    private Properties getNacosProperties(String namespace) {\n        Properties properties = new Properties();\n        properties.put(SERVER_ADDR, getServerAddr());\n        properties.put(USERNAME, Objects.toString(getUsername(), \"\"));\n        properties.put(PASSWORD, Objects.toString(getPassword(), \"\"));\n        properties.put(NAMESPACE, namespace);\n        properties.put(UtilAndComs.NACOS_NAMING_LOG_NAME, getLogName());\n        String endpoint = getEndpoint();\n        if (endpoint.contains(\":\")) {\n            int index = endpoint.indexOf(\":\");\n            properties.put(ENDPOINT, endpoint.substring(0, index));\n            properties.put(ENDPOINT_PORT, endpoint.substring(index + 1));\n        }\n        else {\n            properties.put(ENDPOINT, endpoint);\n        }\n\n        properties.put(ACCESS_KEY, getAccessKey());\n        properties.put(SECRET_KEY, getSecretKey());\n        properties.put(CLUSTER_NAME, getClusterName());\n        properties.put(NAMING_LOAD_CACHE_AT_START, getNamingLoadCacheAtStart());\n\n\/\/        enrichNacosDiscoveryProperties(properties);\n        return properties;\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @description: naocs\u670d\u52a1\u53d1\u73b0\u91cd\u5199\n * @author: rookie0peng\n * @date: 2022\/8\/30 1:10\n *\/\npublic class NacosServiceDiscoveryV2 extends NacosServiceDiscovery {\n\n    private final NacosDiscoveryPropertiesV2 discoveryProperties;\n\n    private final NacosShareProperties nacosShareProperties;\n\n    private final NacosServiceManager nacosServiceManager;\n\n    public NacosServiceDiscoveryV2(NacosDiscoveryPropertiesV2 discoveryProperties, NacosShareProperties nacosShareProperties, NacosServiceManager nacosServiceManager) {\n        super(discoveryProperties, nacosServiceManager);\n        this.discoveryProperties = discoveryProperties;\n        this.nacosShareProperties = nacosShareProperties;\n        this.nacosServiceManager = nacosServiceManager;\n    }\n\n    \/**\n     * Return all instances for the given service.\n     * @param serviceId id of service\n     * @return list of instances\n     * @throws NacosException nacosException\n     *\/\n    public List&lt;ServiceInstance&gt; getInstances(String serviceId) throws NacosException {\n        String group = discoveryProperties.getGroup();\n        List&lt;Instance&gt; instances = discoveryProperties.namingServiceInstance()\n                .selectInstances(serviceId, group, true);\n        if (isEmpty(instances)) {\n            Map&lt;String, Set&lt;String&gt;&gt; namespaceGroupMap = nacosShareProperties.getNamespaceGroupMap();\n            Map&lt;String, NamingService&gt; namespace2NamingServiceMap = discoveryProperties.shareNamingServiceInstances();\n            for (Map.Entry&lt;String, NamingService&gt; entry : namespace2NamingServiceMap.entrySet()) {\n                String namespace;\n                NamingService namingService;\n                if (isNull(namespace = entry.getKey()) || isNull(namingService = entry.getValue()))\n                    continue;\n                Set&lt;String&gt; groupNames = namespaceGroupMap.get(namespace);\n                List&lt;Instance&gt; shareInstances;\n                if (isEmpty(groupNames)) {\n                    shareInstances = namingService.selectInstances(serviceId, group, true);\n                    if (nonEmpty(shareInstances))\n                        break;\n                } else {\n                    shareInstances = new ArrayList&lt;&gt;();\n                    for (String groupName : groupNames) {\n                        List&lt;Instance&gt; subShareInstances = namingService.selectInstances(serviceId, groupName, true);\n                        if (nonEmpty(subShareInstances)) {\n                            shareInstances.addAll(subShareInstances);\n                        }\n                    }\n                }\n                if (nonEmpty(shareInstances)) {\n                    instances = shareInstances;\n                    break;\n                }\n            }\n        }\n        return hostToServiceInstanceList(instances, serviceId);\n    }\n\n    \/**\n     * Return the names of all services.\n     * @return list of service names\n     * @throws NacosException nacosException\n     *\/\n    public List&lt;String&gt; getServices() throws NacosException {\n        String group = discoveryProperties.getGroup();\n        ListView&lt;String&gt; services = discoveryProperties.namingServiceInstance()\n                .getServicesOfServer(1, Integer.MAX_VALUE, group);\n        return services.getData();\n    }\n\n    public static List&lt;ServiceInstance&gt; hostToServiceInstanceList(\n            List&lt;Instance&gt; instances, String serviceId) {\n        List&lt;ServiceInstance&gt; result = new ArrayList&lt;&gt;(instances.size());\n        for (Instance instance : instances) {\n            ServiceInstance serviceInstance = hostToServiceInstance(instance, serviceId);\n            if (serviceInstance != null) {\n                result.add(serviceInstance);\n            }\n        }\n        return result;\n    }\n\n    public static ServiceInstance hostToServiceInstance(Instance instance,\n                                                        String serviceId) {\n        if (instance == null || !instance.isEnabled() || !instance.isHealthy()) {\n            return null;\n        }\n        NacosServiceInstance nacosServiceInstance = new NacosServiceInstance();\n        nacosServiceInstance.setHost(instance.getIp());\n        nacosServiceInstance.setPort(instance.getPort());\n        nacosServiceInstance.setServiceId(serviceId);\n\n        Map&lt;String, String&gt; metadata = new HashMap&lt;&gt;();\n        metadata.put(\"nacos.instanceId\", instance.getInstanceId());\n        metadata.put(\"nacos.weight\", instance.getWeight() + \"\");\n        metadata.put(\"nacos.healthy\", instance.isHealthy() + \"\");\n        metadata.put(\"nacos.cluster\", instance.getClusterName() + \"\");\n        metadata.putAll(instance.getMetadata());\n        nacosServiceInstance.setMetadata(metadata);\n\n        if (metadata.containsKey(\"secure\")) {\n            boolean secure = Boolean.parseBoolean(metadata.get(\"secure\"));\n            nacosServiceInstance.setSecure(secure);\n        }\n        return nacosServiceInstance;\n    }\n\n    private NamingService namingService() {\n        return nacosServiceManager\n                .getNamingService(discoveryProperties.getNacosProperties());\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @description: \u91cd\u5199nacos\u670d\u52a1\u53d1\u73b0\u7684\u81ea\u52a8\u914d\u7f6e\n * @author: rookie0peng\n * @date: 2022\/8\/30 1:08\n *\/\n@Configuration(proxyBeanMethods = false)\n@ConditionalOnDiscoveryEnabled\n@ConditionalOnNacosDiscoveryEnabled\n@AutoConfigureBefore({NacosDiscoveryAutoConfiguration.class})\npublic class NacosDiscoveryAutoConfigurationV2 {\n\n    @Bean\n    @ConditionalOnMissingBean\n    public NacosDiscoveryPropertiesV2 nacosProperties(NacosShareProperties nacosShareProperties) {\n        return new NacosDiscoveryPropertiesV2(nacosShareProperties);\n    }\n\n    @Bean\n    @ConditionalOnMissingBean\n    public NacosServiceDiscovery nacosServiceDiscovery(\n            NacosDiscoveryPropertiesV2 discoveryPropertiesV2, NacosShareProperties nacosShareProperties, NacosServiceManager nacosServiceManager\n    ) {\n        return new NacosServiceDiscoveryV2(discoveryPropertiesV2, nacosShareProperties, nacosServiceManager);\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u672c\u4ee5\u4e3a\u95ee\u9898\u5230\u8fd9\u5c31\u7ed3\u675f\u4e86\uff0c\u4f46\u6700\u540e\u81ea\u6d4b\u65f6\u53d1\u73b0\u7a0b\u5e8f\u6839\u672c\u4e0d\u8d70 <code>Nacos<\/code> \u7684\u670d\u52a1\u53d1\u73b0\u903b\u8f91\uff0c\u800c\u662f\u6267\u884c <code>Ribbon<\/code> \u7684\u8d1f\u8f7d\u5747\u8861\u903b\u8f91<code>com.netflix.loadbalancer.AbstractLoadBalancerRule<\/code>\u3002<\/p>\n\n\n\n<p>\u4e0d\u8fc7\u5b9e\u73b0\u7c7b\u662f <code>com.alibaba.cloud.nacos.ribbon.NacosRule<\/code>\uff0c\u7ee7\u7eed\u57fa\u4e8e <code>NacosRule<\/code> \u91cd\u5199\u8d1f\u8f7d\u5747\u8861\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @description: \u5171\u4eabnacos\u547d\u540d\u7a7a\u95f4\u89c4\u5219\n * @author: rookie0peng\n * @date: 2022\/8\/31 2:04\n *\/\npublic class ShareNacosNamespaceRule extends AbstractLoadBalancerRule {\n\n    private static final Logger LOGGER = LoggerFactory.getLogger(ShareNacosNamespaceRule.class);\n\n    @Autowired\n    private NacosDiscoveryPropertiesV2 nacosDiscoveryPropertiesV2;\n    @Autowired\n    private NacosShareProperties nacosShareProperties;\n\n    \/**\n     * \u91cd\u5199choose\u65b9\u6cd5\n     *\n     * @param key\n     * @return\n     *\/\n    @SneakyThrows\n    @Override\n    public Server choose(Object key) {\n        try {\n            String clusterName = this.nacosDiscoveryPropertiesV2.getClusterName();\n            DynamicServerListLoadBalancer loadBalancer = (DynamicServerListLoadBalancer) getLoadBalancer();\n            String name = loadBalancer.getName();\n\n            NamingService namingService = nacosDiscoveryPropertiesV2\n                    .namingServiceInstance();\n            List&lt;Instance&gt; instances = namingService.selectInstances(name, true);\n            if (CollectionUtils.isEmpty(instances)) {\n                LOGGER.warn(\"no instance in service {}, then to get share service's instance\", name);\n                List&lt;Instance&gt; shareNamingService = this.getShareNamingService(name);\n                if (nonEmpty(shareNamingService))\n                    instances = shareNamingService;\n                else\n                    return null;\n            }\n            List&lt;Instance&gt; instancesToChoose = instances;\n            if (org.apache.commons.lang3.StringUtils.isNotBlank(clusterName)) {\n                List&lt;Instance&gt; sameClusterInstances = instances.stream()\n                        .filter(instance -&gt; Objects.equals(clusterName,\n                                instance.getClusterName()))\n                        .collect(Collectors.toList());\n                if (!CollectionUtils.isEmpty(sameClusterInstances)) {\n                    instancesToChoose = sameClusterInstances;\n                }\n                else {\n                    LOGGER.warn(\n                            \"A cross-cluster call occurs\uff0cname = {}, clusterName = {}, instance = {}\",\n                            name, clusterName, instances);\n                }\n            }\n\n            Instance instance = ExtendBalancer.getHostByRandomWeight2(instancesToChoose);\n\n            return new NacosServer(instance);\n        }\n        catch (Exception e) {\n            LOGGER.warn(\"NacosRule error\", e);\n            return null;\n        }\n    }\n\n\n    @Override\n    public void initWithNiwsConfig(IClientConfig iClientConfig) {\n\n    }\n\n    private List&lt;Instance&gt; getShareNamingService(String serviceId) throws NacosException {\n        List&lt;Instance&gt; instances = Collections.emptyList();\n        Map&lt;String, Set&lt;String&gt;&gt; namespaceGroupMap = nacosShareProperties.getNamespaceGroupMap();\n        Map&lt;String, NamingService&gt; namespace2NamingServiceMap = nacosDiscoveryPropertiesV2.shareNamingServiceInstances();\n        for (Map.Entry&lt;String, NamingService&gt; entry : namespace2NamingServiceMap.entrySet()) {\n            String namespace;\n            NamingService namingService;\n            if (isNull(namespace = entry.getKey()) || isNull(namingService = entry.getValue()))\n                continue;\n            Set&lt;String&gt; groupNames = namespaceGroupMap.get(namespace);\n            List&lt;Instance&gt; shareInstances;\n            if (isEmpty(groupNames)) {\n                shareInstances = namingService.selectInstances(serviceId, true);\n                if (nonEmpty(shareInstances))\n                    break;\n            } else {\n                shareInstances = new ArrayList&lt;&gt;();\n                for (String groupName : groupNames) {\n                    List&lt;Instance&gt; subShareInstances = namingService.selectInstances(serviceId, groupName, true);\n                    if (nonEmpty(subShareInstances)) {\n                        shareInstances.addAll(subShareInstances);\n                    }\n                }\n            }\n            if (nonEmpty(shareInstances)) {\n                instances = shareInstances;\n                break;\n            }\n        }\n        return instances;\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u81f3\u6b64\u95ee\u9898\u5f97\u4ee5\u89e3\u51b3\u3002<\/p>\n\n\n\n<p>\u5728 <code>Nacos<\/code> \u4e0a\u914d\u7f6e\u597d\u5171\u4eab <code>namespace<\/code> \u548c <code>group<\/code> \u540e\uff0c\u5c31\u80fd\u591f\u8fdb\u884c\u8de8\u547d\u540d\u7a7a\u95f4\u8bbf\u95ee\u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># nacos\u5171\u4eab\u547d\u540d\u7a7a\u95f4\u914d\u7f6e \u793a\u4f8b\nnacos.share.entities&#91;0].namespace=e6ed2017-3ed6-4d9b-824a-db626424fc7b\nnacos.share.entities&#91;0].groupNames&#91;0]=DEFAULT_GROUP\n# \u6307\u5b9a\u670d\u52a1\u4f7f\u7528\u5171\u4eab\u7684\u8d1f\u8f7d\u5747\u8861\u89c4\u5219\uff0cservice-id\u662f\u6ce8\u518c\u5230nacos\u4e0a\u7684\u670d\u52a1id\uff0cShareNacosNamespaceRule\u9700\u8981\u5199\u5168\u9650\u5b9a\u540d\nservice-id.ribbon.NFLoadBalancerRuleClassName=***.***.***.ShareNacosNamespaceRule<\/code><\/pre>\n\n\n\n<p><strong>\u6ce8\u610f\uff1a\u5982\u679c Java \u9879\u76ee\u7684 <code>nacos discovery<\/code> \u7248\u672c\u7528\u7684\u662f <code>2021.1<\/code>\uff0c\u5219\u4e0d\u9700\u8981\u91cd\u5199 Ribbon \u7684\u8d1f\u8f7d\u5747\u8861\u7c7b\uff0c\u56e0\u4e3a\u8be5\u7248\u672c\u7684 Nacos \u4e0d\u4f9d\u8d56 Ribbon\u3002<\/strong><\/p>\n\n\n\n<p><strong>2.2.1.RELEASE \u7248\u672c<\/strong>\u7684 <code>nacos discovery<\/code> \u4f9d\u8d56 Ribbon.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1151\" height=\"625\" src=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/6-1024x556.png\" alt=\"\" class=\"wp-image-1143\" srcset=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/6-1024x556.png 1024w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/6-300x163.png 300w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/6-768x417.png 768w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/6.png 1151w\" sizes=\"(max-width: 1151px) 100vw, 1151px\" \/><\/figure>\n\n\n\n<p><strong>2021.1 \u7248\u672c<\/strong>\u7684 <code>nacos discovery<\/code> \u4e0d\u4f9d\u8d56 Ribbon\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"500\" src=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/7-1024x500.png\" alt=\"\" class=\"wp-image-1144\" srcset=\"https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/7-1024x500.png 1024w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/7-300x146.png 300w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/7-768x375.png 768w, https:\/\/ligai.cn\/blog\/wp-content\/uploads\/2022\/12\/7.png 1066w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2>\u56db<strong>\u3001\u603b\u7ed3<\/strong><\/h2>\n\n\n\n<p>\u4e3a\u4e86\u8fbe\u5230\u5171\u4eab\u547d\u540d\u7a7a\u95f4\u7684\u9884\u671f\uff0c\u6784\u601d\u3001\u67e5\u627e\u8d44\u6599\u3001\u5b9e\u73b0\u903b\u8f91\u3001\u8c03\u8bd5\uff0c\u524d\u540e\u4e00\u5171\u82b1\u8d39 4 \u5929\u65f6\u95f4\u3002\u6210\u5c31\u611f\u6ee1\u6ee1\u7684\u540c\u65f6\uff0c\u7b14\u8005\u4e5f\u53d1\u73b0\u8be5\u529f\u80fd\u4ecd\u5b58\u5728\u5171\u4eab\u670d\u52a1\u7f13\u5b58\u7b49\u53ef\u4f18\u5316\u7a7a\u95f4\uff0c\u7559\u5f85\u540e\u7eed\u5b9e\u73b0\u3002<\/p>\n\n\n\n<h2><strong>\u4e94\u3001\u53c2\u8003\u6587\u732e<\/strong><\/h2>\n\n\n\n<p>[1] Registration Center: Can services in different namespaces be called from each other? [EB\/OL]. https:\/\/github.com\/alibaba\/nacos\/issues\/1176, 2019-05-07\/2022-11-29.<\/p>\n\n\n\n<p>[2] \u91cd\u5199Nacos\u670d\u52a1\u53d1\u73b0\u903b\u8f91\u52a8\u6001\u4fee\u6539\u8fdc\u7a0b\u670d\u52a1IP\u5730\u5740 [EB\/OL]. https:\/\/www.cnblogs.com\/changxy-codest\/p\/14632574.html, 2021-04-08\/2022-11-29.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>&gt;&gt; LigaAI \u5f80\u671f\u7cbe\u5f69\u9605\u8bfb &lt;&lt;<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/ligai.cn\/blog\/sharing\/1126.html\">\u534a\u4e2a\u6708\u4e0a\u7ebf\u4e00\u4e2a\u65b0\u4ea7\u54c1\uff0c\u7334\u5b50\u65e0\u9650\u662f\u600e\u4e48\u505a\u7684\uff1f<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/ligai.cn\/blog\/sharing\/1122.html\">\u5982\u4f55\u57fa\u4e8eGitHub Pages+Hexo\uff0c\u642d\u5efa\u4e2a\u4eba\u535a\u5ba2\uff1f<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/ligai.cn\/blog\/sharing\/1116.html\">\u591a\u6d4b\u8bd5\u73af\u5883\u7684\u52a8\u6001\u4f38\u7f29\u5b9e\u8df5<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/ligai.cn\/blog\/alige\/1114.html\">\u88ab\u5ffd\u60a0\u5165\u5751\u540e\uff0c\u6211\u5982\u4f55\u8ba9\u4ea7\u54c1\u300c\u8d77\u6b7b\u56de\u751f\u300d\uff1f<\/a><\/p>\n\n\n\n<p><strong>\u4e86\u89e3\u66f4\u591a\u654f\u6377\u5f00\u53d1\u3001\u9879\u76ee\u7ba1\u7406\u3001\u884c\u4e1a\u52a8\u6001\u7b49\u6d88\u606f\uff0c\u5173\u6ce8\u6211\u4eec\u7684\u56e2\u961f\u535a\u5ba2\u6216\u70b9\u51fb\u00a0<a href=\"https:\/\/ligai.cn\/\">LigaAI-\u667a\u80fd\u7814\u53d1\u534f\u4f5c\u5e73\u53f0<\/a>\uff0c\u5728\u7ebf\u7533\u8bf7\u4f53\u9a8c\u6211\u4eec\u7684\u4ea7\u54c1\u3002<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u95ee\u9898\u80cc\u666f \u5728\u5f00\u53d1\u67d0\u4e2a\u516c\u5171\u5e94\u7528\u65f6\uff0c\u7b14\u8005\u53d1\u73b0\u8be5\u516c\u5171\u5e94\u7528\u7684\u6570\u636e\u662f\u6240\u6709\u6d4b\u8bd5\u73af\u5883\uff08\u5047\u8bbe\u5b58\u5728 dev\/dev2\/dev &#8230; <a title=\"\u6280\u672f\u5206\u4eab | \u591a\u4e2a\u670d\u52a1\u5668\u5982\u4f55\u8de8\u547d\u540d\u7a7a\u95f4\uff0c\u8bbf\u95ee\u516c\u5171\u670d\u52a1\uff1f\" class=\"read-more\" href=\"https:\/\/ligai.cn\/blog\/sharing\/1136.html\" aria-label=\"\u7ee7\u7eed\u9605\u8bfb\u6280\u672f\u5206\u4eab | \u591a\u4e2a\u670d\u52a1\u5668\u5982\u4f55\u8de8\u547d\u540d\u7a7a\u95f4\uff0c\u8bbf\u95ee\u516c\u5171\u670d\u52a1\uff1f\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[15,25],"_links":{"self":[{"href":"https:\/\/ligai.cn\/blog\/wp-json\/wp\/v2\/posts\/1136"}],"collection":[{"href":"https:\/\/ligai.cn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ligai.cn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ligai.cn\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ligai.cn\/blog\/wp-json\/wp\/v2\/comments?post=1136"}],"version-history":[{"count":1,"href":"https:\/\/ligai.cn\/blog\/wp-json\/wp\/v2\/posts\/1136\/revisions"}],"predecessor-version":[{"id":1145,"href":"https:\/\/ligai.cn\/blog\/wp-json\/wp\/v2\/posts\/1136\/revisions\/1145"}],"wp:attachment":[{"href":"https:\/\/ligai.cn\/blog\/wp-json\/wp\/v2\/media?parent=1136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ligai.cn\/blog\/wp-json\/wp\/v2\/categories?post=1136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ligai.cn\/blog\/wp-json\/wp\/v2\/tags?post=1136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}