【问题标题】:spring-boot 2.5.5 property "spring.config.import" not defined?spring-boot 2.5.5 属性“spring.config.import”未定义?
【发布时间】: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.propertiesbootstrap.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


    【解决方案1】:

    在 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
    

    More Info

    【讨论】:

      猜你喜欢
      • 2021-08-03
      • 2020-10-26
      • 2020-10-30
      • 1970-01-01
      • 2021-12-16
      • 2021-10-15
      • 1970-01-01
      • 2020-06-14
      • 2019-10-18
      相关资源
      最近更新 更多