升级 SpringBoot 2.3.5 到 2.4.0

Upgrade SpringBoot 2.3.5 To 2.4.0

我想将我的 Spring 引导版本从 2.3.5 升级到 2.4,但我有问题..

应用程序在 2.3.5 运行 秒内没有任何问题

我用这个更新了我的 POM,POM 上没有错误。 :

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->
        <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

我有 4 个这样的应用程序属性: 申请-local.properties 申请-d.yaml 应用-...yaml 申请...

我在本地,所以我想运行申请-local.properties。 为此,我在 SpringBootTool 的“虚拟机参数”中使用: -Dspring.profiles.active=local

现在,Spring 2.4.0 不应用本地配置文件,运行应用程序没有任何属性。

对于我的测试: 我已经抑制了 VM 参数,将 spring.profiles.active=local 放在 application.properties 中(因为 application.properties 也加载了 application-local.properties)

我在我的应用程序中使用和不使用 spring.config.activate.on-profile=local 进行了测试-local.properties

我读了那两个: https://docs.spring.io/spring-boot/docs/2.4.0-SNAPSHOT/reference/html/spring-boot-features.html#boot-features-external-config-files

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Config-Data-Migration-Guide

感谢您的帮助!

已知问题,由属性中的注释引起

示例:

# I'm a comment
custom.properties.url=http://stack.com
# I'm another

使用 public 版本 > 2.4.0 或使用 2.4.1-SNAPSHOT 请参阅此内容和其他相关内容:https://github.com/spring-projects/spring-boot/issues/24263

升级到 Spring 后问题已解决 Spring Boot 2.4.0 是要使用

mvn spring-boot:运行 -Dspring-boot.run.profiles=dev

而不是使用 -Dspring.profiles.active