spring-boot分環境打包爲jar包

1.pom配置java

    <!-- 多環境打包 start -->
    <profiles>
        <!-- 開發環境配置 -->
        <profile>
            <id>dev</id>
            <properties>
                <profiles.active>dev</profiles.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <!-- 測試環境配置 -->
        <profile>
            <id>test</id>
            <properties>
                <profiles.active>test</profiles.active>
            </properties>
        </profile>
        <!-- 正式環境 -->
        <profile>
            <id>online</id>
            <properties>
                <profiles.active>online</profiles.active>
            </properties>
        </profile>
    </profiles>
    <!-- 多環境打包 end -->

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.class</include>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>*.xml</include>
                    <include>*.properties</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources/conf/${profiles.active}</directory>
            </resource>
        </resources>
    </build>

2.打包命令maven

mvn clean package -Dmaven.test.skip=true -Ptest測試

3.啓動命令ui

nohup java -jar demo.jar > /dev/null 2>&1 &spa

相關文章
相關標籤/搜索