SpringBoot maven 使用特定的 application.properties 构建战争 [英] SpringBoot maven build war using specific application.properties

查看:31
本文介绍了SpringBoot maven 使用特定的 application.properties 构建战争的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含三个 application.properties 文件的 Spring Boot 应用程序:

I have a Spring Boot application with has three application.properties files :

  1. 应用程序属性
  2. application-qa.properties
  3. application-prod.properties

我想使用 maven 构建战争,具体取决于应用程序部署的环境,即 devqaprod.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆