我想将我的SpringBoot版本从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个类似的应用程序属性:application-local.properties应用程序-d.yaml应用程序-。。。yaml应用程序。。。
我在本地,所以我想运行application-local.properties。为此,我在";VM自变量";SpringBootTool的:-Dspring.profiles.active=local
现在,有了它和Spring 2.4.0,它不应用本地配置文件,而是在没有任何属性的情况下运行应用程序。
对于我的测试:我已经抑制了VM参数,将spring.profiles.active=local
放在application.properties中(因为application.properties也加载了applicationlocal.properties(
我在application-local.properties 中使用和不使用spring.config.activate.on-profile=local
进行了测试
我读了这两篇:https://docs.spring.io/spring-boot/docs/2.4.0-SNAPSHOT/reference/html/spring-boot-features.html#boot-具有外部配置文件
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
随着公开发布>2.4.0或使用2.4.1-SNAPSHOT请参阅:https://github.com/spring-projects/spring-boot/issues/24263
升级到Spring Boot 2.4.0后,我解决了使用的问题
mvn-spring-boot:run-Dspring-boot.run.profiles=dev
而不是使用-Dspring.profiles.active