今天学习NACOS配置文件时,报错Param ‘serviceName‘ is illegal, serviceName is blank,但是我在bootstrap.yml文件中配置了服务名
父工程引入的依赖版本为最新的2021.1
<!--nacos的管理依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2021.1</version>
<type>pom</type>
</dependency>
该服务引入的依赖版本如下,均为最新版本
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2021.1</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2021.1</version>
</dependency>
原因:该版本不再默认优先加载bootstrap.yml文件
解决办法:添加spring-cloud-starter-bootstrap依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>3.0.4</version>
</dependency>