通过 spring-boot-maven-plugin 将特定属性文件应用到应用程序 运行 很热门吗?

Hot to apply particular properties file to an application run by spring-boot-maven-plugin?

有一个属性文件 application-special.yml,我用 spring-boot-maven-plugin 在本地启动应用程序。当文件位于 main/resources 时,将 special 作为配置文件名称传递给命令就足够了:

clean spring-boot:run -D spring-boot.run.profiles=special

如何在项目外应用这个属性文件?

您可以使用 spring-boot 提供任意数量的外部 属性 文件,如下所示:

mvn spring-boot:run -Dspring-boot.run.arguments="--spring.config.additional-location=file:/directory_path/filename.yml,file:/directory_path/filename2.yml"