application.yml 配合 pom.xml

spring:
profiles:
active: @spring.profiles.active@

pom.xml 文件

src/main/resourcestrueorg.apache.maven.pluginsmaven-resources-plugin2.7@falseprodprodtruedevdev
    </profile>
    <profile>
        <!-- 测试环境 -->
        <id>test</id>
        <properties>
            <spring.profiles.active>test</spring.profiles.active>
        </properties>
    </profile>
</profiles>

分环境打包
mvn clean package -Pprod -Dmaven.test.skip=true

mvn clean package -Pdev -Dmaven.test.skip=true

相关文章:

猜你喜欢
相关资源
相似解决方案