添加阿里云的镜像到maven的setting.xml配置中,这样就不须要每次在pom中,添加镜像仓库的配置,在mirrors节点下面添加子节点:maven
<mirrors> <mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> </mirrors>
注:< mirrorOf>能够设置为哪一个中央仓库作镜像,为名为“central”的中央仓库作镜像,写做< mirrorOf>central< /mirrorOf>;为全部中央仓库作镜像,写做< mirrorOf>< /mirrorOf>。Maven默认中央仓库的id 为 central。id是惟一的。
重要:除非你有把握,不然不建议使用< mirrorOf>< /mirrorOf>的方式。ide
单项目配置时,须要修改pom.xml文件。pom.xml文件中,没有mirror元素。在pom.xml文件中,经过覆盖默认的中央仓库的配置,实现中央仓库地址的变动。阿里云
<repositories> <repository> <id>central</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <layout>default</layout> <!-- 是否开启发布版构件下载 --> <releases> <enabled>true</enabled> </releases> <!-- 是否开启快照版构件下载 --> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories>
注:Maven默认中央仓库的id 为 central。id是惟一的。所以使用< id>central< /id>覆盖了默认的中央仓库。url