當須要根據不一樣的環境, 採用不一樣的依賴庫、配置、插件, 能夠使用profiles. 配置要點是activation激活條件,在如下幾種狀況下,profile將被激活:html
查看profile是否被激活, 使用命令 mvn help:active-profiles
條件匹配規則:
###jdk
測試jdk版本是否匹配, 也能夠限定一個範圍, 例如 <jdk>(1.6, 1.8]</jdk> 限制jdk的版本爲1.7, 1.8
版本號範圍的語法, 見http://maven.apache.org/pom.html#Dependency_Version_Requirement_Specification
###os
操做系統是否匹配, 它又有4個子項, <arch><family><name><version>, 使用命令mvn -v能夠查看當前操做系統的信息:java
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
當<os>下所列舉出的條件都匹配時, <os>選項纔算匹配
###property 判斷java系統變量是否匹配, 包含-D定義的系統變量, 不包含在pom.xml中定義的properties, 也不包含環境變量.apache
<profiles> <profile> <activation> <property> <name>debug</name> <value></value> </property> </activation> </profile> </profiles>
若是value字段爲空(沒有可見字符), 則表示匹配任何值
###file
判斷文件是否存在或者不存在, 它又有兩個子項<exists>和<missing>. 這兩個子項, 只能選其一, 若是這兩個子項都存在, <missing>將被忽略; 文件路徑只能填相對路徑。例如windows
<profiles> <profile> <activation> <file> <exists>${basedir}/debug.properties</exists> </file> </activation> </profile> </profiles>
<file>標籤不識別${project.basedir}, 應該屬於這個版本的bug.maven