其他分享
首页 > 其他分享> > 14.Springboot多环境配置2

14.Springboot多环境配置2

作者:互联网

1.主配置文件application.yml
spring:
  profiles:
    active: @profile.active@ # 需要在pom文件中指定变量
#    active: pro
#    include: mvc
    group:
      "pro": mvc
      "test": redis

2.dev配置文件application-dev.yml
server:
  port: 8080
3.test配置文件application-test.yml
server:
  port: 8081
4.pro配置文件application-pro.yml
server:
  port: 8082
5.mvc配置文件application-mvc.yml
spring:
  mvc:
    async:
      request-timeout: 60
6.pom.xml文件增加profile标签
<profiles>
    <profile>
        <id>dev</id>
        <properties>
            <profile.active>dev</profile.active>
        </properties>
    </profile>

    <profile>
        <id>test</id>
        <properties>
            <profile.active>test</profile.active>
        </properties>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>

    <profile>
        <id>pro</id>
        <properties>
            <profile.active>pro</profile.active>
        </properties>
    </profile>
</profiles>
7.步骤
1.通过在pom.xml中指定默认环境,启动/打包相应的环境

标签:14,配置文件,pro,配置,application,mvc,test,yml,Springboot
来源: https://www.cnblogs.com/NIAN2011/p/16658008.html