为什么要弃用 @ConfigurationProperties 中的方法位置?

Han*_*Lee 5 configuration spring-boot

我正在尝试在 Spring Boot 中配置多个“.yml”,例如......

应用程序.yml

spring:
    profile: local
Run Code Online (Sandbox Code Playgroud)

api.yml

spring:
    profile: local
myapi:
  url: localhost/...
Run Code Online (Sandbox Code Playgroud)

所以,我在@ConfigurationProperties中找到了locations方法。但是,它在 1.4.x 中已被弃用

Deprecated. as of 1.4 in favor of configuring the environment directly with additional locations
Run Code Online (Sandbox Code Playgroud)

我该如何配置这种情况?

And*_*son 2

您可以用来spring.config.name更改要查找的配置文件名称。可以使用逗号分隔的列表配置多个名称。就您而言,您希望将其设置为application,api.