其他分享
首页 > 其他分享> > SpringBoot|多环境配置

SpringBoot|多环境配置

作者:互联网

一、idea配置文件

 

 application.yml

spring:
  profiles:
    active: dev

 application-dev.yml

server:
  port: 8081

 application-test.yml

server:
  port: 8082

 application-uat.yml

server:
  port: 8083

 application-prod.yml

server:
  port: 8084

启动:

active: dev

 二、pom文件配置

    <profiles>
        <!-- 开发环境-->
        <profile>
            <id>dev</id>
            <properties>
                <spring.profiles.active>dev</spring.profiles.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>

        <!-- 测试环境-->
        <profile>
            <id>test</id>
            <properties>
                <spring.profiles.active>test</spring.profiles.active>
            </properties>
        </profile>

        <!-- 预发布环境-->
        <profile>
            <id>uat</id>
            <properties>
                <spring.profiles.active>uat</spring.profiles.active>
            </properties>
        </profile>

        <!-- 线上环境-->
        <profile>
            <id>prod</id>
            <properties>
                <spring.profiles.active>prod</spring.profiles.active>
            </properties>
        </profile>
    </profiles>

 以jar包运行服务

 

标签:SpringBoot,配置,环境,uat,dev,port,application,server,yml
来源: https://www.cnblogs.com/Durant0420/p/15068551.html