maven学习之二

时间:2023-03-10 02:49:07
maven学习之二

三 profile介绍

可以有多个地方定义profile。定义的地方不同,它的作用范围也不同。

(1)    针对于特定项目的profile配置我们可以定义在该项目的pom.xml中。

(2)    针对于特定用户的profile配置,我们可以在用户的settings.xml文件中定义profile。该文件在用户家目录下的“.m2”目录下。

(3)  全局的profile配置。全局的profile是定义在Maven安装目录下的“conf/settings.xml”文件中的。

profile定义在settings.xml中:

  profile定义在settings.xml中时意味着该profile是全局的,它会对所有项目或者某一用户的所有项目都产生作用。因为它是全局的,所以在settings.xml中只能定义一些相对而言范围宽泛一点的配置信息,比如远程仓库等。具体而言,能够定义在settings.xml中的信息有<repositories>、<pluginRepositories>和<properties>

profile定义在pom.xml中:

在pom.xml中的profile可以定义更多的信息。主要有以下这些:

l  <repositories>

l  <pluginRepositories>

l  <dependencies>

l  <plugins>

l  <properties>

l  <dependencyManagement>

l  <distributionManagement>

l  还有build元素下面的子元素,主要包括:

<defaultGoal>

<resources>

<testResources>

<finalName>

2 .maven超级pom:3.xxx版本之后在:maven安装目录下的:/lib/maven-model-builder-version.jar中 \org\apache\maven\mode目录中的pom-4.0.0.xml