maven profile

          1、執行:mvn -P[profile_id]
          2、激活activation

          <project>
            
            
          <profiles>
              
          <profile>
                
          <id>dev</id>
                
          <activation>
                  
          <activeByDefault>false</activeByDefault>
                  
          <jdk>1.5</jdk>
                  
          <os>
                    
          <name>Windows XP</name>
                    
          <family>Windows</family>
                    
          <arch>x86</arch>
                    
          <version>5.1.2600</version>
                  
          </os>
                  
          <property>
                    
          <name>mavenVersion</name>
                    
          <value>2.0.5</value>
                  
          </property>
                  
          <file>
                    
          <exists>file2.properties</exists>
                    
          <missing>file1.properties</missing>
                  
          </file>
                
          </activation>
                
              
          </profile>
            
          </profiles>
          </project>

          3.當使用屬性激活的時候
          <profiles>
                  
          <profile>
                      
          <id>test</id>
                      
          <activation>
                          
          <property>
                              
          <name>test.bingo</name>
                              
          <value>kkk</value>
                          
          </property>
                      
          </activation>
          </profile>
          </profiles>

          可以在命令行中mvn -Dtest.bingo=kkk或者mvn -Ptest這兩種方式激活該profile對pom設置的進行覆蓋。

          4.當使用變量替換的時候
          <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">
              
              
          <build>
                  
          <resources>
                      
          <resource>
                        
          <directory>src/main/filter-resources</directory>
                        
          <filtering>true</filtering>
                      
          </resource>
                  
          </resources>

              
          </build>
              
          <profiles>
                  
          <profile>
                      
          <id>test</id>
                      
          <activation>
                          
          <property>
                              
          <name>test.bingo</name>
                              
          <value>kkk</value>
                          
          </property>
                      
          </activation>
                      
          <properties>
                          
          <env.dir>222</env.dir>
                      
          </properties>
                      
          <build>
                                  
          </profile>
              
          </profiles>
          </project>

          過濾指定的目錄下文件,如果該文件中有${env.dir}的變量,就會被222給覆蓋掉。

          posted on 2009-07-13 13:15 andy.kong 閱讀(1544) 評論(2)  編輯  收藏 所屬分類: maven

          評論

          # re: maven profile 2009-11-16 18:02 Shouling

          是bingo嗎?  回復  更多評論   

          # re: maven profile[未登錄] 2009-11-16 18:22 andy

          @Shouling
          這里的bingo只是一個字符串命名,沒有其他含義  回復  更多評論   

          公告

          師者,所以傳道授業解惑也!

          導航

          <2009年7月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          統計

          常用鏈接

          留言簿

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 金门县| 赣州市| 蓬莱市| 汝城县| 莱西市| 台州市| 固原市| 嘉鱼县| 克山县| 炎陵县| 台湾省| 修水县| 阿拉尔市| 扶绥县| 无为县| 肇庆市| 贡嘎县| 曲靖市| 宽城| 湄潭县| 雅安市| 南召县| 武宣县| 吉水县| 海兴县| 夏河县| 澄城县| 平昌县| 泌阳县| 阳原县| 来宾市| 穆棱市| 富蕴县| 南通市| 山阴县| 临海市| 驻马店市| 黄龙县| 吉木萨尔县| 凭祥市| 灵山县|