解决方案:设置maven代理解决 idea 更新maven仓库error,跟新索引缓慢问题,网上大部分方案都有问题

1,940 阅读1分钟

先说解决方案,再说废话

万分感谢 v2ex.com/t/510461 中 "v2ex用户: xbigfat" 的回答

解决方案:在maven的 setting.xml的<proxies> 中分别设置http与https的代理,单单设置http代理不行

  	<proxy>
        <id>forHttp</id>
        <active>true</active>
        <protocol>http</protocol>
        <host>127.0.0.1</host>
        <port>1081</port>
        <nonProxyHosts>localhost.com|127.0.0.1</nonProxyHosts>
    </proxy>
    <proxy>
        <id>forHttps</id>
        <active>true</active>
        <protocol>https</protocol>
        <host>127.0.0.1</host>
        <port>1081</port>
        <nonProxyHosts>localhost.com|127.0.0.1</nonProxyHosts>
    </proxy>

注意:

  1. http与https代理的 host 与 port 根据你们的代理软件自行配置。在我的代理软件中http与https端口配置都是1081
  2. 更新的时候更新默认的apache仓库,实测nexus-maven-repository-index.gz5分钟下载完成,之后idea花了大概10分钟解压索引