通过maven打包

Posted 万里独行侠

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过maven打包相关的知识,希望对你有一定的参考价值。

<profiles>
        <profile>
            <id>dev</id>
            <!--<activation>-->
                <!--<activeByDefault>true</activeByDefault>-->
            <!--</activation>-->
            <properties>
                <environment>dev</environment>
            </properties>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <environment>test</environment>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <environment>prod</environment>
            </properties>
        </profile>

    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>application-dev.properties</exclude>
                    <exclude>application-test.properties</exclude>
                    <exclude>application-prod.properties</exclude>
                    <exclude>application.properties</exclude>
                </excludes>
            </resource>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
                <includes>
                    <include>application-${environment}.properties</include>
                    <include>application.properties</include>
                </includes>
            </resource>
        </resources>
    </build>
</profiles>

在application.properties配置

## dev | prod | test
[email protected]@

 

以上是关于通过maven打包的主要内容,如果未能解决你的问题,请参考以下文章

maven中如何打包源代码

Maven 打包可运行 jar

Maven(12) build 构建的使用

springcloud maven打包部署

Maven - settings.xml里的offline节点的作用

通过maven打包