zoukankan      html  css  js  c++  java
  • Eclipse Maven profiles 多环境配置,测试环境与开发环境分开打包

    1.将开发环境、测试环境、生产环境的配置文件分开存放,如下图:

    2.在Maven中配置不同的环境打包配置文件的路径,配置如下:

    <profiles>  
            <profile>  
                <!-- 开发环境 -->  
                <id>dev</id>  
                <properties>  
                    <env>dev</env>
                </properties>  
                <activation>  
                    <!-- 默认激活该profile节点-->
                    <activeByDefault>true</activeByDefault>  
                </activation> 
                <build>
                    <resources>
                        <resource>
                            <directory>src/main/resources-env/dev</directory>
                        </resource>
                        <resource>
                            <directory>src/main/resources</directory>
                        </resource>
                    </resources>
                </build>
            </profile>  
            <profile>  
                <!-- 测试环境 -->  
                <id>qa</id>  
                <properties>  
                    <env>qa</env>
                </properties>
                <build>
                    <resources>
                        <resource>
                            <directory>src/main/resources-env/qa</directory>
                        </resource>
                        <resource>
                            <directory>src/main/resources</directory>
                        </resource>
                    </resources>
                </build>
            </profile>    
            <profile>  
                <!-- 生产环境 -->  
                <id>online</id>  
                <properties>  
                    <env>online</env>
                </properties>  
                <build>
                    <resources>
                        <resource>
                            <directory>src/main/resources-env/online</directory>
                        </resource>
                        <resource>
                            <directory>src/main/resources</directory>
                        </resource>
                    </resources>
                </build>
            </profile> 
        </profiles>  

    3.项目打包前的配置

      右击项目->Maven->填入要打包的环境:

      

    4.项目打包,当项目打包完以后解压后就可以看到在配置文件根目录中,已经把要打包的环境的配置文件都放进去了!

  • 相关阅读:
    POJ 1703 Find them, Catch them
    POJ 2236 Wireless Network
    POJ 2010 Moo University
    POJ 2184 Cow Exhibition
    POJ 3280 Cheapest Palindrome
    POJ 3009 Curling 2.0
    POJ 3669 Meteor Shower
    POJ 2718 Smallest Difference
    POJ 3187 Backward Digit Sums
    POJ 3050 Hopscotch
  • 原文地址:https://www.cnblogs.com/raphael5200/p/6677549.html
Copyright © 2011-2022 走看看