They modify the POM at build time, and are meant to be used in complementary sets to give equivalent-but-different parameters for a set of target environments (providing, for example, the path of the appserver root in the development, testing, and production environments).
Profiles specified in the POM can modify the following POM elements:
- <repositories>
- <pluginRepositories>
- <dependencies>
- <plugins>
- <properties> (这是compile time的maven properties,不是system properties)
- <modules>
- <reporting>
- <dependencyManagement>
- <distributionManagement>
- a subset of the <build> element, which consists of:
- <defaultGoal>
- <resources>
- <testResources>
- <finalName>
可以用mvn help:active-profiles来查看被active的profiles。
在spring configuration file里用的${sut.env}是system properties,如果想让maven properties来代替它,需要将这个spring xml file包含进<build><resources>里面。否则的话,就需要在profile里加上<build><plugin><configuration><systemPropertyVariables>。