zoukankan      html  css  js  c++  java
  • maven 多环境打包

    项目开发需要有多个环境,一般为开发,测试,预发,正式4个环境,通过maven可以实现按不同环境进行打包部署,命令为: 

    mvn package -P dev

    其中“dev“为环境的变量id, 可以自己定义, 我定义的名称为:dev,qa,pre,prod , 具体在pom.xml中的配置如下:

    <?xml version="1.0" encoding="UTF-8"?>  
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><profiles>  
            <profile>  
                <id>dev</id>  
                <properties>  
                    <env>dev</env>  
                </properties>  
                <activation>  
                    <activeByDefault>true</activeByDefault>  <!-- 默认启动环境 -->
                </activation>  
            </profile>  
            <profile>  
                <id>qa</id>  
                <properties>  
                    <env>qa</env>  
                </properties>  
            </profile>  
            <profile>  
                <id>pre</id>  
                <properties>  
                    <env>pre</env>  
                </properties>  
            </profile>  
            <profile>  
                <id>prod</id>  
                <properties>  
                    <env>prod</env>  
                </properties>  
            </profile>  
        </profiles>  
          
      <build>  
            <filters>  
                <filter>config/${env}.properties</filter> 
           <!-- env 对应上面的 dev qa prod 指定了环境配置文件的路径 如../config-${env}.properties --> </filters> <resources> <resource> <directory>src/main/resources</directory> <!-- maven项目的默认配置文件路径,环境配置文件里的值将替换该路径下的值 --> <filtering>true</filtering> </resource> </resources> ...... </build> </project>
  • 相关阅读:
    Silverlight 4 新特性之NotificationWindow
    如何理解JavaScript原型
    惹恼程序员的十件事
    浅谈HTTP中Get与Post的区别
    asp中Access与Sql Server数据库区别总结
    SQL208语句
    jQuery源码分析
    3. 在 as 和 强制类型转换之间,优先使用 as 操作符。
    揭秘10项必学的.NET技术
    如何设置远程访问SQL Server2005
  • 原文地址:https://www.cnblogs.com/caer/p/6169316.html
Copyright © 2011-2022 走看看