1.配置文件

分别添加各个环境的配置文件

2.pom文件

添加如下代码

<build>

<resources>

        <resource>

            <directory>src/main/resources</directory>

            <includes>

            <include>**/*.properties</include>

            <include>**/*.xml</include>

            </includes>

            <!-- 排除dev、test目录下的文件 -->

            <excludes>

                <exclude>dev/*</exclude>

                <exclude>test/*</exclude>

                <exclude>beta/*</exclude>

                <exclude>product/*</exclude>

            </excludes>

            <filtering>true</filtering>     

        </resource>

        <resource>

            <directory>src/main/resources</directory>

            <!-- 包含,若没有指定则默认为 activeByDefault 标签定义的profile -->

            <includes>

                 <include>${profiles.activation}/*</include>

            </includes>

        </resource>

</resources>

</build>

 

<profiles>

        <profile>

            <id>dev</id>

            <properties>

                <profiles.activation>dev</profiles.activation>

            </properties>

            <activation>

                <!--默认为dev环境打包方式-->

                <activeByDefault>true</activeByDefault>

            </activation>

        </profile>

        <profile>

            <id>test</id>

            <properties>

                <profiles.activation>test</profiles.activation>

            </properties>

        </profile>

        <profile>

            <id>beta</id>

            <properties>

                <profiles.activation>beta</profiles.activation>

            </properties>

        </profile>

        <profile>

            <id>product</id>

            <properties>

                <profiles.activation>product</profiles.activation>

            </properties>

        </profile>

</profiles>

3.jenkins多环境自动打包

参考:https://www.cnblogs.com/smail-bao/p/6121462.html

修改命令:

clean install -Dmaven.test.skip=true -Ptest

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐