Maven配置阿里云仓库

血红的双手。 提交于 2020-01-09 19:03:40

Maven默认使用国外镜像,下载速度很慢,我们可以将仓库地址配置成国内的,比如阿里云的,复制以下代码,替换settings.xml文件中的mirrors模块:

<mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
	 <!-- 阿里云仓库 -->
	 <mirror>
	     <id>alimaven</id>
	     <mirrorOf>central</mirrorOf>
	     <name>aliyun maven</name>
	     <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
	 </mirror>
	 
	 <!-- 中央仓库1 -->
	 <mirror>
	     <id>repo1</id>
	     <mirrorOf>central</mirrorOf>
	     <name>Human Readable Name for this Mirror.</name>
	     <url>http://repo1.maven.org/maven2/</url>
	 </mirror>
	 
	 <!-- 中央仓库2 -->
	 <mirror>
	     <id>repo2</id>
	     <mirrorOf>central</mirrorOf>
	     <name>Human Readable Name for this Mirror.</name>
	     <url>http://repo2.maven.org/maven2/</url>
	 </mirror>

  </mirrors>

Ps:如果在公司或者企业工作,一般大型企业都有自己的中央仓库,将mirror配置成所在企业的即可!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!