springcloud-alibaba接入nacos注册中心

1,引入依赖,所有模块都要用到,多模块里可以将依赖放到父模块或者公用模块

        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>

2,windows版nacos 中间件安装 ,
(1) 直接下载编译好的release版的
(2)github下不了的,可以到gitee拉取源码,指定版本的tag,不要拉取最新的,进行编译。因为nacos也是java语言开发的。

官网教程:https://nacos.io/zh-cn/docs/v2/quickstart/quick-start.html

git clone https://github.com/alibaba/nacos.git
cd nacos/
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U  
ls -al distribution/target/

// change the $version to your actual path
cd distribution/target/nacos-server-$version/nacos/bin

运行:
startup.cmd -m standalone 单机运行

3,子模块配置

spring:
  cloud:
    nacos:
      discovery:
        server-addr: 192.168.56.1:8848
  application:
    name: product

4,启动类添加注解
@EnableDiscoveryClient

5,nacos 查看

127.0.0.1:8848
默认账号密码: nacos nacos
posted @   李很好  阅读(37)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示