profile能夠讓咱們定義一系列的配置信息,而後指定其激活條件。這樣咱們就能夠定義多個profile,而後每一個profile對應不一樣的激活條件和配置信息,從而達到不一樣環境使用不一樣配置信息的效果。好比說,咱們能夠經過profile定義在jdk1.5以上使用一套配置信息,在jdk1.5如下使用另一套配置信息;或者有時候咱們能夠經過操做系統的不一樣來使用不一樣的配置信息,好比windows下是一套信息,linux下又是另一套信息,等等。linux
下面是不一樣操做系統使用不一樣配置信息的示例代碼,pom.xml文件中添加:windows
1 <profiles> 2 <profile> 3 <id>dev</id> 4 <activation> 5 <activeByDefault>true</activeByDefault> 6 <os> 7 <family>Windows</family> 8 </os> 9 </activation> 10 <properties> 11 <filter.path>src\main\resources\config-dev.properties</filter.path> 12 </properties> 13 </profile> 14 <profile> 15 <id>production</id> 16 <activation> 17 <activeByDefault>false</activeByDefault> 18 <os> 19 <family>Linux</family> 20 </os> 21 </activation> 22 <properties> 23 <filter.path>src\main\resources\config.properties</filter.path> 24 </properties> 25 </profile> 26 </profiles>