神器下载需要花费大量时间而没有结果

时间:2015-04-21 10:35:25

标签: java maven-3 artifact

请帮我解决以下情况: 1.我有两个Nexus存储库 2.我在C:\ Users \ Login.m2中有两个settings.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <servers>
        <server>
            <id>releases</id>
            <username>developer</username>
            <password></password>
        </server>
        <server>
            <id>snapshots</id>
            <username>developer</username>
            <password></password>
        </server>
    </servers>

    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <repositories>
                <repository>
                    <id>releases</id>
                    <name>Releases Repository</name>
                    <url>http://30.30.20.40:8085/nexus/content/repositories/releases/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>snapshots</id>
                    <name>Snapshots Repository</name>
                    <url>http://30.30.20.40:8085/nexus/content/repositories/snapshots/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>thirdparty</id>
                    <name>3-d Party Artifacts Repository</name>
                    <url>http://30.30.20.40:8085/nexus/content/repositories/thirdparty/</url>
                               <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>
</settings>

并在C:\ apache-maven-3.2.3 \ conf:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <servers>
   <server>
      <id>snapshots</id>
      <username>deployment</username>
      <password>@@@@@@@@</password>
   </server>

   <server>
            <id>releases</id>
            <username>developer</username>
            <password>@@@@@@</password>
   </server>
  <server>
            <id>snapshots</id>
            <username>developer</username>
            <password>@@@@@@</password>
    </server>

    <server>
            <id>thirdparty</id>
            <username>developer</username>
            <password>@@@@@@@@@@</password>
    </server>
 </servers>



  <profiles>

  <profile>
    <id>nexus</id>
    <repositories>
             <repository>
                <id>nexus-repo</id>
                <name>Nexus repo</name>
                <url>http://192.22.0.17:8080/nexus-webapp-2.11.0-02/content/groups/public/</url>
                <releases>
                  <enabled>true</enabled>
                </releases>
                <snapshots>
                  <enabled>true</enabled>
                </snapshots>
             </repository>

    </repositories>

</profile>

  <profile>
    <id>adc</id>
    <repositories>
           <repository>
                    <id>releases</id>
                    <name> Releases Repository</name>
                    <url>http://30.30.20.40:8085/nexus/content/repositories/releases/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
           </repository>

        <repository>
                    <id>snapshots</id>
                    <name>Snapshots Repository</name>
                    <url>http://30.30.20.40:8085/nexus/content/repositories/snapshots/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>

          <repository>
            <id> thirdparty</id>
            <name>3-d Party Artifacts Repository</name>
                <url>http://30.30.20.40:8085/nexus/content/repositories/thirdparty/</url>
                    <releases>
                <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
           </repository>


    </repositories>

    <pluginRepositories>
      <pluginRepository>
        <id>nexus-repo</id>
        <name>Nexus repo </name>
        <url>http://192.22.0.17:8080/nexus-webapp-2.11.0-02/content/groups/public/</url>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
        </snapshots>
      </pluginRepository>

  <pluginRepository>
        <id>releases</id>
        <name> Releases Repository</name>
        <url>http://30.30.20.40:8085/nexus/content/repositories/releases/</url>
      <releases>
        <enabled>true</enabled>
    </releases>
        <snapshots>
            <enabled>false</enabled>
    </snapshots>
      </pluginRepository>


    </pluginRepositories>
</profile>
  </profiles>
<activeProfiles>
  <activeProfile>nexus</activeProfile>
  <activeProfile>adc</activeProfile>
</activeProfiles>
</settings>
  1. 问题是:当我运行“mvn clean package”时,下载需要花费很多时间:
  2.   

    [INFO]正在下载:   http://30.30.20.40:8085/nexus/content/repositories/releases/org/apache/httpcomponents/project/4.1.1/project-4.1.1.pom   [INFO]正在下载:   http://30.30.20.40:8085/nexus/content/repositories/thirdparty/org/apache/httpcomponents/project/4.1.1/project-4.1.1.pom

    看起来Maven尝试在一个存储库中下载工件,当失败时尝试在另一个存储库中下载工件。

    我正在尝试更正C:\ Program Files \ Java \ jdk1.7.0_67 \ jre \ lib \ amd64 \ jvm.cfg,如此处所述http://www.ninthavenue.com.au/why-is-maven-so-slow 但没有效果。

    这是我的其他设置:

      

    java -version

         

    java版“1.8.0_40”Java(TM)SE运行时环境(构建   1.8.0_40-b26)Java HotSpot(TM)64位服务器VM(内置25.40-b25,混合模式)

         

    mvn -version Apache Maven 3.2.3   (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-12T00:58:10 + 04:00)     Maven home:C:\ apache-maven-3.2.3 \ bin .. Java版本:1.7.0_67,   供应商:Oracle Corporation Java home:C:\ Program   Files \ Java \ jdk1.7.0_67 \ jre默认语言环境:ru_RU,平台编码:   Cp1251操作系统名称:“windows 7”,版本:“6.1”,arch:“amd64”,系列:   “窗口”

3 个答案:

答案 0 :(得分:1)

您可以使用 -T 命令在多个线程中运行 maven,如下所示,

mvn clean install -T 4

这将在 4 个线程中执行 Maven 构建。您可以尝试mvn --help了解更多信息。

答案 1 :(得分:0)

我的情况,如下所述,问题出在安全设置中。安全人员在我的电脑上禁用(设置)安全代理,现在工件下载正常。谢谢你,金比。

答案 2 :(得分:0)

Repocache 加速下载。很了不起。

添加 repocache.cfg

[mvn.upstream.releases]
url = http://30.30.20.40:8085/nexus/content/repositories/releases

这将在 mvn/releases 缓存包。

更改 $HOME/.m2/settings.xml 添加:

<repository>
  <id>releases</id>
  <url>http://127.0.0.1:5000/mvn/releases</url>
</repository>

这对我有用。