zoukankan      html  css  js  c++  java
  • maven profile 的作用

    maven 的profile  可以是我们通过编译时指定 -P 来实现 使用不同的 属性变量。 

    比如: 

     <profiles>
               <profile>
                   <id>local</id>
                   <properties>
                        <xx>我是local环境的xx的值</xx>
                   </properties>
               </profile>
    <profile>
                   <id>dev</id>
                   <properties>
                        <xx>我是dev的xx的值</xx>
                   </properties>
               </profile>
    </profiles>

    xx 等同于属性值

    <properties>
    <xx>fdsfdsfds</xx>
    </properties>

    但是 这个时候 有了指定不同 -P 使用不同配置的功能。 

    所有在maven pom 文件中 可配置的 参数都可以 通过这种方式 配置 不同场景下使用不同的 参数。 

    比如: 可以使用profiles 配置不同镜像地址 。 这样就可以区分仓库了。

    注意事项: maven 的 setting.xml  和  项目 pom.xml 中配置的  profile 会同时存在。在 -P 的时候可以使用多个 如:  -P  dev, devParam   逗号分割

      <profile>
          <id>dev</id>
          <repositories>
              <repository>
                 <id>central</id>
              <name>Central</name>
              <url>http://url/repository/maven-public</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
              </snapshots>
          </repository>
        </repositories>
      </profile>
      <profile>
          <id>uat</id>
          <repositories>
            <repository>
              <id>central</id>
              <name>Central</name>
              <url>http://url/repository/maven-public</url>
              <releases>
                  <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
              </snapshots>
            </repository>
        </repositories>
      </profile>
    </profiles>
    
     <activeProfiles>
      <activeProfile>dev</activeProfile>
    </activeProfiles>
  • 相关阅读:
    仓位管理 – 1.理论篇
    作为首席架构师,我是如何选择并落地架构方案的?
    asp.net MVC 应用程序的生命周期
    微服务架构优缺点
    一位同事对 Rafy 框架的一些建议及我的回复
    .NET 版本区别,以及与 Windows 的关系
    MIS性能优化常见问题与方案(辅助项目组性能优化的总结贴)
    何时使用静态 API
    2011奥斯卡最佳纪录片《监守自盗(Inside Job)》小结
    Rafy 框架
  • 原文地址:https://www.cnblogs.com/zhangchenglzhao/p/15080955.html
Copyright © 2011-2022 走看看