解决方案:
引入spring-cloud-commons-dependencies依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-commons-dependencies</artifactId> <version>2.2.5.RELEASE</version> </dependency>
引入spring-cloud-context依赖;bootstrap.yml只在SpringCloud下生效,要想在SpringBoot框架生效要引入SpringCloud的相关依赖
<!--spring-cloud-context 2020-->
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-context</artifactId> <version>2.2.5.RELEASE</version> </dependency>
建议在使用SpringCloud开发微服务的时候,使用bootstrap.yml配置文件替代application.yml,
因为在SpringBoot程序启动时,bootstrap.yml的加载顺序优先级大于application.yml ;