SpringBoot 与 nacos 最新版本整合

本着【版本最新法力最强】的原则,全部使用最新版本:

  • springboot 的版本为 2.7.3
  • nacos 的版本为 0.2.12
  • nacos server 的版本为 2.1.1
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.3</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>
<dependency>
      <groupId>com.alibaba.boot</groupId>
      <artifactId>nacos-discovery-spring-boot-starter</artifactId>
      <version>0.2.12</version>
</dependency>

springboot 的 2.7.3 版本,支持nacos的0.2.7以上版本。 

nacos的默认端口号是8848

启动nacos server 和  右击启动工程后,

1,POST 请求  http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=test&ip=127.0.0.1&port=8080 ,发送成功会返回信息  ok  

2,GET 请求 http://localhost:8081/discovery/get?serviceName=test  ,请求成功会返回如下信息:

[
    {
        "instanceId": "127.0.0.1#8080#DEFAULT#DEFAULT_GROUP@@test",
        "ip": "127.0.0.1",
        "port": 8080,
        "weight": 1.0,
        "healthy": true,
        "enabled": true,
        "ephemeral": true,
        "clusterName": "DEFAULT",
        "serviceName": "DEFAULT_GROUP@@test",
        "metadata": {},
        "instanceHeartBeatTimeOut": 15000,
        "instanceHeartBeatInterval": 5000,
        "instanceIdGenerator": "simple",
        "ipDeleteTimeout": 30000
    }
]

 

最后贴上下载链接:

链接:https://pan.baidu.com/s/1GrMS6TBBYaJn8GtGjomFAw

提取码:0707

里面也附上了 nacos server 下载 ,先在bin目录启动,然后再右击启动工程。

nacos 管理页面链接及密码:

http://localhost:8848/nacos/index.html

nacos

nacos

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章