如果我们要在项目中单独指定远程仓库得地址的话
1.pom.xml添加配置
添加repositories节点
<repositories>
<repository>
<id>aliyun</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
其中< release>标签和snapshot标签表示是否从远程仓库引入release或者snapshot版本
配置之后 : 问题maven依赖的插件 没有使用阿里云仓库的地址
1.发现maven的插件库还是用的是默认的仓库地址
2.项目的依赖是使用的阿里云仓库地址
添加pluginRepositories节点
maven命令需要的插件(比如clean、install都是maven的插件),走的还是默认的repository。
查看maven的官方文档(http://maven.apache.org/pom.h... ),可以看到pom中除了repositories节点之外,还有一个关于仓库的节点是pluginRepositories:
Repositories are home to two major types of artifacts. The first are artifacts that are used as dependencies of other artifacts. These are the majority of plugins that reside within central. The other type of artifact is plugins. Maven plugins are themselves a special type of artifact. Because of this, plugin repositories may be separated from other repositories (although, I have yet to hear a convincing argument for doing so). In any case, the structure of the pluginRepositories element block is similar to the repositories element. The pluginRepository elements each specify a remote location of where Maven can find new plugins.
所以我们还需要再pom中增加pluginRepositories才可以。
完整的pom文件如下:
<repositories>
<repository>
<id>aliyun</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-plugin</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
再次运行: 都走了阿里云的仓库