gpt4 book ai didi

maven - spring 什么时候使用 application-dev.properties 和 application.properties

转载 作者:行者123 更新时间:2023-12-04 14:55:49 25 4
gpt4 key购买 nike

我有几个 Spring Boot 应用程序。它们都是 maven 项目,并且在所有项目中,我都有针对不同环境的单独配置文件,例如 application.properties、application-dev.properties、application-uat.properties。当我从 IDE 运行应用程序时,它有时从 application.properties 文件中读取,有时从 application-dev.properties 文件中读取。我使用 IntelliJ IDEA 进行开发,但我一直无法弄清楚是什么决定了要读取哪个文件。是依赖于 IDE 还是 Spring 中有一些配置决定选择哪个属性文件?

最佳答案

很可能你在 Idea 中的一些运行配置已经配置了 Spring “配置文件”来运行。当您使用例如“dev”配置文件运行 Spring Boot 应用程序时,然后 application-dev.properties除了 application.properties 之外,还将读取文件.见 here欲了解更多信息

关于maven - spring 什么时候使用 application-dev.properties 和 application.properties,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50522397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com