上一篇文章中已经启动了配置中心的Nacos Server,这篇文章说一下客户端如何配置
-
创建springboot工程(nacos客户端)
我是用的是springboot2.0.8版本,工程最初的目录情况如下
-
引入依赖
引入nacos客户端依赖
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
</dependencies>
<!-- dependency management -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>0.2.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
我用的是当前最新的0.2.1.RELEASE版本,
注:springboot1.5.x版本要用0.1.x版本的nacos客户端,由于我是用的是springboot2.0.8版本,所以是用的是0.2.1版本
大家可以在maven仓库中查看当前的所有的版本https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-alibaba-nacos-config
所以最终我的整个pom文件如下