【发布时间】:2021-12-09 01:58:29
【问题描述】:
将 spring-boot:2.3.11.RELEASE 升级到 spring-boot:2.5.5 和 spring-cloud:Hoxton.SR11 到 spring-cloud:2020.0.4 后,spring-boot:run 失败:
***************************
APPLICATION FAILED TO START
***************************
Description:
No spring.config.import property has been defined
Action:
Add a spring.config.import=configserver: property to your configuration.
If configuration is not required add spring.config.import=optional:configserver: instead.
To disable this check, set spring.cloud.config.enabled=false or
spring.cloud.config.import-check.enabled=false.
建议很清楚,所以我添加了
spring.cloud.config.enabled=false
spring.cloud.config.import-check.enabled=false
spring.config.import=optional:configserver:
application.properties 和 bootstrap.properties 文件
在 application.properties 我必须注释掉 spring.config.import=optional:configserver: 行,否则它会以 java.lang.IllegalStateException: Unable to load config data from 'optional:configserver:' ......... Caused by: java.lang.IllegalStateException: File extension is not known to any PropertySourceLoader 失败
由于我不需要在 bootstrap.properties 中将其注释掉,因此可能会完全忽略其中的值
但是应用程序本身失败的方式与没有添加任何新属性的方式相同。
任何想法是什么问题? spring.config.import=... 的正确格式是什么?
编辑: 添加依赖后
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
它不再忽略 bootstrap.properties 中的属性,所以我也必须在此处注释掉“spring.config.import=optional:configserver:”。但是应用程序仍然失败并显示“没有定义 spring.config.import 属性”
【问题讨论】:
标签: spring-boot spring-cloud spring-cloud-config