idea 中的 profiles 详解

博客介绍了Java中profile的作用,主要是解决不同环境下变量和配置问题。它通常出现在settings.xml和pom.xml中,前者用于仓库选择,后者用于激活环境配置,还提及了与profile打包搭配的build代码配置及相关properties文件内容。

在这里插入图片描述
profile 主要是为了解决不同环境所需的不同变量、配置等问题.

profile 一般出现在两个地方:settings.xml,pom.xml

在 settings.xml 时,一般用来做仓库的选择(只使用 aliyun 仓库可以这样配置 settings.xml)

在 pom.xml 时,一般用来激活环境配置

<profiles>
        <profile>
            <id>local</id>
            <properties>
                <profiles.active>local</profiles.active>
            </properties>
        </profile>
        <profile>
            <id>elk</id>
            <properties>
                <profiles.active>elk</profiles.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
    </profiles>

与profile打包时搭配使用的build 代码如下配置(结合application-${env}.properties文件使用)

application-${env}.properties 中的部分内容

application-prepub.properties 中 spring.profiles.active=prepub-qa
application-daily.properties 中 spring.profiles.active=daily
application.properties 中 spring.profiles.active=@env@

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黄毛火烧雪下

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值