SpringBoot maven 使用特定的 application.properties 构建战争 [英] SpringBoot maven build war using specific application.properties
问题描述
我有一个包含三个 application.properties
文件的 Spring Boot 应用程序:
I have a Spring Boot application with has three application.properties
files :
- 应用程序属性
- application-qa.properties
- application-prod.properties
我想使用 maven 构建战争,具体取决于应用程序部署的环境,即 dev
、qa
或 prod代码>.
I want build a war using maven by using one of the properties depending on the environment the application with be deployed too i.e dev
, qa
or prod
.
我该怎么做.我是 Spring Boot 的新手.
How can I do this. I'm pretty new to Spring Boot.
推荐答案
设置 SPRING_PROFILES_ACTIVE
环境变量将激活预期的配置文件.例如,为了激活qa
配置文件,将SPRING_PROFILES_ACTIVE
环境变量设置为qa
.阅读有关配置文件特定属性的更多信息 此处.
Setting the SPRING_PROFILES_ACTIVE
environment variable will activate the intended profile. for example, in order to activate the qa
profile, set the SPRING_PROFILES_ACTIVE
environment variable to qa
. Read more about profile specific properties here in Spring Boot Documentation.
这篇关于SpringBoot maven 使用特定的 application.properties 构建战争的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!