千家信息网

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

发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,这篇文章主要介绍"如何配置Nacos服务注册与发现",在日常操作中,相信很多人在如何配置Nacos服务注册与发现问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"如何配置N
千家信息网最后更新 2026年11月02日如何配置Nacos服务注册与发现

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

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 界面截图

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@Configurationpublic class NacosDiscoveryConfiguration {}

2.3 配置

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

2.4 界面截图

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

0