码迷,mamicode.com
首页 > 编程语言 > 详细

springboot项目maven配置多环境

时间:2020-01-12 21:55:19      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:frame   director   group   dea   cut   overwrite   output   compiler   resources   

maven配置多环境

 

 <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!--     配置默认跳过单元测试 结束-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>

            <!-- 编译 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <compilerArguments>
                        <extdirs>${project.basedir}/lib</extdirs>
                    </compilerArguments>
                </configuration>
            </plugin>

            
            <!--  配置多环境-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <overwrite>true</overwrite>
                            <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources/profiles/${active.profile}</directory>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


        </plugins>
        <finalName>DXBChannel</finalName>

        <!--        配置资源目录-->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>profiles/*</exclude>
                </excludes>
                <!--<filtering>true</filtering>-->
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
    </build>


    <!--配置环境的profile-->
    <profiles>
        <!--dev默认激活,使用idea Spring Boot 配置启动工程,需要dev的配置-->
        <profile>
            <id>dev</id>
            <properties>
                <active.profile>dev</active.profile>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <active.profile>test</active.profile>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <active.profile>prod</active.profile>
            </properties>
        </profile>
    </profiles>
</project>

 

springboot项目maven配置多环境

标签:frame   director   group   dea   cut   overwrite   output   compiler   resources   

原文地址:https://www.cnblogs.com/zhangshiwen/p/12184797.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!