Spring Boot 2.5.x Bootstrap 配置不生效问题

Bootstrap 配置不生效问题

最近项目组在搭建环境,用的版本Spring Boot 2.5.x 版本
在集成Nacos 服务的时候,发现bootstrap.properties 配置不生效

在这里插入图片描述

一直读取application.yml 配置 此时的我…
在这里插入图片描述
经过多次查找方案,定位到问题

解决方案

经过测试
Spring Boot 版本 小于 2.4.0 版本

<dependency>
     <groupId>org.springframework.cloud</groupId>
     <artifactId>spring-cloud-context</artifactId>
</dependency>

Spring Boot 版本 大于 2.4.0 版本,添加以下依赖

<dependency>
     <groupId>org.springframework.cloud</groupId>
     <artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>

除此之外要注意一个非常关键的问题点!!!!就是版本,如果你当前项目是已经引用Cloud结构需要检查 你当前boot 版本是否匹配 你的Cloud 版本
参考 Spring,IO 官网

在这里插入图片描述
否则 会出现如下报错:

  • Change Spring Boot version to one of the following versions [2.3.x, 2.4.x] .
    You can find the latest Spring Boot versions here [https://spring.io/projects/spring-boot#learn].
    If you want to learn more about the Spring Cloud Release train compatibility, you can visit this page [https://spring.io/projects/spring-cloud#overview] and check the [Release Trains] section.
    If you want to disable this check, just set the property [spring.cloud.compatibility-verifier.enabled=false]

当前boot 项目版本 2.5.x 版本 ,引用的3.0.3 或者大家去maven存储库查找一下

            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bootstrap</artifactId>
            <version>3.0.3</version>
        </dependency>

配置完成以后,即可正常使用
在这里插入图片描述

  • 7
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值