配置其他的远程仓库
<project>
...
<repositories>
<repository>
<id>maven-net-cn</id>
<name>Maven China Mirror</name>
<url>http://maven.net.cn/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven-net-cn</id>
<name>Maven China Mirror</name>
<url>http://maven.net.cn/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
...
</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>完全一样
也可以在setting.xml中配置
在xml中配置的话,就是配置一次就OK了,就不用每个项目都配置一下
<settings>
...
<profiles>
<profile>
<id>dev</id>
<!-- repositories and pluginRepositories here-->
</profile>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
...
</settings>
不能简单的将 < respositories> < pluginRespositories>放进去,要先定义一个id为dev的profile,将所有repositories以及pluginRepositories元素放到这个profile中,然后,使用< activeProfiles>元素自动激活该profile。
这样就不用再重复的在pom里面定义了
//也可以在profiles里面启动默认启动
<profiles>
<id></id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profiles>