mavenrepository配置
eclipse maven 配置修改:
maven repository 配置
Maven缺省的本地仓库地址为${user.home}/.m2/repository。也就是说,⼀个⽤户会对应的拥有⼀个本地仓库。
你也可以⾃定义本地仓库的位置,修改${user.home}/.l:
了解了本地仓库,接着了解⼀下Maven缺省的远程仓库,即Maven中央仓库
在POM中配置远程仓库
1. <project>
2. ...
3.  <repositories>
4.    <repository>
5.      <id>maven-net-cn</id>
6.      <name>Maven China Mirror</name>
7.      <url>maven/content/groups/public/</url>
8.      <releases>
9.        <enabled>true</enabled>
10.      </releases>
11.      <snapshots>
12.        <enabled>false</enabled>
13.      </snapshots>
14.    </repository>
15.  </repositories>
16.  <pluginRepositories>
17.    <pluginRepository>
18.      <id>maven-net-cn</id>
19.      <name>Maven China Mirror</name>
20.      <url>maven/content/groups/public/</url>
21.      <releases>
22.        <enabled>true</enabled>
23.      </releases>
24.      <snapshots>
25.        <enabled>false</enabled>
26.      </snapshots>
27.    </pluginRepository>
28.  </pluginRepositories>
29. ...
30. </project>
我们先看⼀下<repositories>的配置,你可以在它下⾯添加多个<repository> ,每个<repository>都有它唯⼀的ID,⼀个描述性的name,以及最重要的,远程仓库的url。此外,<releases><enabled>true</enabled></releases>告诉Maven可以从这个仓库下载releases版本的构件,⽽<snapshots><enabled>false</enabled></snapshots>告诉Maven不要从这个仓库下载snapshot版本的构件。禁⽌从公共仓库下载snapshot构件是推荐的做法,因为这些构件不稳定,且不受你控制,你应该避免使⽤。当然,如果你想使⽤局域⽹内组织内部的仓库,你可以激活snapshot的⽀持。
⾄于<pluginRepositories>,这是配置Maven从什么地⽅下载插件构件(Maven的所有实际⾏为都由其插件完成)。该元素的内部配置和
<repository>完全⼀样,不再解释。
在l中配置远程仓库
1. <settings>
2.  ...
3.  <profiles>
4.    <profile>
5.      <id>dev</id>
6.      <!-- repositories and pluginRepositories here-->  把上⾯的内容粘贴到这⾥。。。
7.    </profile>
8.  </profiles>
9.  <activeProfiles>
10.    <activeProfile>dev</activeProfile>
11.  </activeProfiles>
12.  ...
13. </settings>
这⾥我们定义⼀个id为dev的profile,将所有repositories以及pluginRepositories元素放到这个profile中,然后,使⽤<activeProfiles>元素⾃动激活该profile。这样,你就不⽤再为每个POM重复配置仓库。active下载
使⽤profile为l添加仓库提供了⼀种⽤户全局范围的仓库配置。