如何配置Nacos服务注册与发现

这篇文章主要介绍“如何配置Nacos服务注册与发现”,在日常操作中,相信很多人在如何配置Nacos服务注册与发现问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何配置Nacos服务注册与发现”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

成都创新互联公司长期为1000多家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为南票企业提供专业的网站设计制作、成都网站建设南票网站改版等技术服务。拥有10余年丰富建站经验和众多成功案例,为您定制开发。

1 服务端

1.1 下载 nacos-server

https://download.csdn.net/download/qq_28336351/14936184

1.2 启动服务

以Mac为例,演示。

进入到 nacos/bin 目录。

启动命令:

sh startup.sh -m standalone

1.3 管理平台

地址:http://localhost:8848/nacos

默认账号:nacos

默认密码:nacos

1.4 停止服务

以Mac为例,演示。

进入到 nacos/bin 目录。

启动命令:

sh shutdown.sh

1.5 界面截图

如何配置Nacos服务注册与发现

如何配置Nacos服务注册与发现

2 客户端

2.1 依赖



    com.alibaba.cloud
    spring-cloud-starter-alibaba-nacos-discovery

2.2 自动配置

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.fengwenyi.demouserservicecore.config;

import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;

/**
 * @author theonefx
 */
@EnableDiscoveryClient
@Configuration
public class NacosDiscoveryConfiguration {
}

2.3 配置

spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.group=springcloud-alibaba-demo

2.4 界面截图

如何配置Nacos服务注册与发现

到此,关于“如何配置Nacos服务注册与发现”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!


当前标题:如何配置Nacos服务注册与发现
路径分享:http://myzitong.com/article/joceod.html