在自己的项目中直接启动 阿里巴巴 nacos 配置与注册中心 服务

前提

  1. 注册与配置中心 nacos 源码:GitHub - alibaba/nacos: an easy-to-use dynamic service discovery, configuration and service management platform for building AI cloud native applications.
  2. 如果项目中使用了 nacos 注册与配置中心,需要从 Releases · alibaba/nacos · GitHub 下载已经编译好的二进制 jar
    包文件,以 3.1.1 版本为例,大小为 189M
  3. 如果要将使用的二进制安装包储存起来代价有点高(近 200M 的大小)
  4. 如果能在项目中直接使用几个 依赖 和 java源文件 直接启动项目是最好的。
    • 分析 3.1.1 版本的项目可知,bootstrap 源码模块
      只有一个 Java 源文件和一个 properties 配置文件,但是使用的部分依赖没有发布到中央
  5. 如果能将 bootstrap 源码模块 所使用的依赖发布到 Maven
    中央仓库,直接引入该模块最方便(项目中的代码最小,并且不会影响编译速度)

直接使用 Maven 依赖的示例

已发布的 nacos-server 等依赖版本

  1. io.xuxiaowei.nacos:nacos-server:3.0.0
  2. io.xuxiaowei.nacos:nacos-server:3.0.0-ALPHA.2
  3. io.xuxiaowei.nacos:nacos-server:3.0.1
  4. io.xuxiaowei.nacos:nacos-server:3.0.2
  5. io.xuxiaowei.nacos:nacos-server:3.0.3
  6. io.xuxiaowei.nacos:nacos-server:3.1.0
  7. io.xuxiaowei.nacos:nacos-server:3.1.0-BETA
  8. io.xuxiaowei.nacos:nacos-server:3.1.1

GitLab Runner CI/CD 流水线自动发布:https://gitlab.xuxiaowei.com.cn/xuxiaowei-io/nacos