Eclipse建立maven項目遇到錯誤

背景介紹:
    在使用Spring tool suite (Eclipse) 建立maven webapp項目總遇到錯誤。詳細錯誤以下。

web

could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (E:\Maven\repository)
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (E:\Maven\repository)



解決過程:
    在控制檯中使用 mvn help:system 命令,發現建立maven project時候下載都是失敗的。所以頗有多是網絡緣由引發的。個人網絡環境使用的代理。所以要給maven的配置文件 %MAVEN_HOME%/conf/settings.xml 加上代理配置:

<proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    -->
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
  </proxies>



結果:
    從新構建maven項目,用  mvn help:system  命令觀察,maven可以成功下載資源!
相關文章
相關標籤/搜索