原文链接:https://juejin.cn/post/7222897190699008060
1、版本关系
2、异常信息
org.springframework.cloud.commons.ConfigDataMissingEnvironmentPostProcessor$ImportException: No spring.config.import set
3、问题原因
在SpringBoot 2.4.x的版本之后,对于bootstrap.properties/bootstrap.yaml配置文件(我们合起来成为Bootstrap配置文件)的支持,需要导入如下的依赖。由于SpringCloud 2020.*以后的版本默认禁用了bootstrap,导致读取配置文件时读取不到该属性。
4、解决办法
Spring Cloud 新版本默认将 Bootstrap 禁用,需要将 spring-cloud-[starter]依赖引入到工程中
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>