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

 

 

 

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