maven分环境 打包

时间:2023-01-17 09:45:52

1 pom.xml配置:

   1.1  locaL本地,prep 测试,prod 生产

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

   1.2 根据环境引入配置文件 

<build>    
      <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>env/**/*</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources/env/${profiles.active}</directory>
                <filtering>true</filtering>
            </resource>
        </resources> 
    </build>

  1.3 配置文件

maven分环境 打包

 

2.maven命令:clean install -P环境名

maven分环境 打包