spring-boot - spring-boot 2.5.5 属性“spring.config.import”未定义?
问题描述
将 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 Cloud 2020 中,您不再需要 bootstrap.properties,导入 spring-cloud-starter-bootstrap仅启用传统方式来使用它。只需删除它...
您需要添加
spring.config.import=optional:configserver:http://your.config.server.com
进入您的 application.properties。但是,我不确定您要达到什么目标,因为您的
spring.cloud.config.enabled=false
推荐阅读
- android - Android - 谷歌地图卡住了
- c# - 第一次调用 WCF 服务会报错
- logout - 在 laravel 8 注销下拉列表中删除单词“测试”
- c# - 如何使用 BsonSerializer.Deserialize 反序列化对象?
- html - 我怎样才能把这部分移到右边?
- python - 在另一个 .py 文件中导入自定义类
- javascript - 将 Object 推送到一个空数组,其中一个 Object 键的值基于空数组,带有一个函数
- maven - IDEA java/maven - 有时不会在标记为“生成的源根”的目录中检测到生成的源
- repo - .repo 新标签 v2.10 时 repo init 失败
- sql - 在 HIVE 中使用 DISTINCT 和 GROUP BY