iMisty的技术栈

iMisty的技术栈

解决maven中心仓库访问速度问题

972
2020-06-23

入职几天,编译公司的项目使用idea中自带的的maven拉取项目依赖包花了几个小时,毕竟没有代理,并且部分模块因为依赖拉取不全导致编译出现Class not Found 错误,于是直接更换阿里等国内的数据源,直接十几分钟就拉取编译完成了,虽然听说阿里云的数据源可能偶尔有坑

1. 修改idea默认的maven配置;并且新建repository

img

2. 修改setting.xml 里面的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>
		<name>aliyun maven</name>
		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
		<mirrorOf>central</mirrorOf>
	</mirror>
	<mirror>
		<id>alimaven</id>
		<mirrorOf>central</mirrorOf>
		<name>aliyun maven</name>
		<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
	</mirror>
	<mirror>
		<id>central</id>
		<name>Maven Repository Switchboard</name>
		<url>http://repo1.maven.org/maven2/</url>
		<mirrorOf>central</mirrorOf>
	</mirror>
  </mirrors>

3. Reload maven project 重新下载repository,会重新加载配置的数据源,然后下载;国内的数据源还是很舒适的,再也不会持续等待发呆了

其他方式 设置代理提速

img