Java Maven错误-传输失败

Java Maven错误-传输失败,java,eclipse,maven,Java,Eclipse,Maven,我正在研究网络上的一些spring示例。我从中得到了一个例子 在eclipse中导入项目时,POM.xml文件中出现错误 Multiple annotations found at this line: - Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from http://repo.maven.apache.org/maven2 was cached in the local re

我正在研究网络上的一些spring示例。我从中得到了一个例子

在eclipse中导入项目时,POM.xml文件中出现错误

Multiple annotations found at this line:
- Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from http://repo.maven.apache.org/maven2 was cached in the 
 local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer 
 artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): null to http://
 repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom
- connection timed out
- Failure to transfer org.apache.maven.plugins:maven-source-plugin:pom:2.0.4 from http://repo.maven.apache.org/maven2 was cached in the 
 local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer 
 artifact org.apache.maven.plugins:maven-source-plugin:pom:2.0.4 from/to central (http://repo.maven.apache.org/maven2): connection timed out to 
 http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-source-plugin/2.0.4/maven-source-plugin-2.0.4.pom
我还尝试删除我的.m2\repository文件夹。但还是会出错


有谁能指导我解决这个问题吗?

您收到一个请求存储库的超时异常。有时工作不正常。还可能存在其他网络问题,如主机dns、网络断开的集线器、网络代理设置等。

此问题主要是因为防火墙更好地使用代理。
settings.xml
(.m2\repository\settings.xml)中,添加相应的
proxy
设置,告诉Maven通过代理下载工件

<settings>
    .......
    <proxies>
        <proxy>
            <active>true</active>
            <protocol>http</protocol>
            <host>your_proxy_host</host>
            <port>your_proxy_port</port>
            <!-- Its optional  if you need user name and password to connect proxy remove comment.
            <username>proxyuser</username>
            <password>somepassword</password>
            <nonProxyHosts>*.yourdomain.com|*.yourOtherDomain.com</nonProxyHosts>
            -->
        </proxy>
    </proxies>
</settings>

.......
真的
http
您的\u代理\u主机
您的\u代理\u端口

是的,我自己也遇到过这个问题。以下是一些其他观察结果:

  • 以前当我遇到这个错误时,我会转到Maven->Update Maven Project,如果这不起作用,Maven->Update Maven Project和“强制更新快照/发布”。这种技术会起作用
  • 过了一段时间,上面的#1停止工作。然而,当我在没有代理的情况下在同一个工作区中构建同一个项目时,它起了作用
  • 使用代理信息应用settings.xml无法解决以下特定问题:
  • 无法转移工件 插件:maven资源插件:pom:2.6 from/to 中央():连接超时

    我还想知道这到底意味着什么:到底是什么在转移,从哪里转移到哪里?我相信最初我们的工作区中有.pom文件,并且基于pom,必要的工件将下载到本地maven存储库中。这些存储库在我们的IDE构建路径中进一步提到

    为什么它对某些工件“超时”,而对其他工件“超时”?而且,这些东西似乎指向“org.eclipse.m2.core”。更准确地说,org.eclipse.m2.core和代理的结合把它搞砸了——作为开发人员,我们无法控制它。这是非常令人沮丧的


    我们不知道的东西可能会严重伤害我们——举个例子——(eclipse+代理)动力学。

    通过大量的谷歌搜索找到了解决方案:除了在settings.xml中添加代理信息外,我还必须添加以下内容以解决问题。同样,只有当涉及代理时,这才是一个问题。这是下一次与日食相关的神秘堆栈跟踪呕吐之前的平静——我猜

      <activeProfiles>
        <activeProfile>securecentral</activeProfile>
      </activeProfiles>
    
      <profiles>
        <profile>
          <id>securecentral</id>
          <repositories>
            <repository>
              <id>central</id>
              <url>https://repo1.maven.org/maven2</url>
              <releases>
                <enabled>true</enabled>
              </releases>
            </repository>
          </repositories>
          <pluginRepositories>
            <pluginRepository>
              <id>central</id>
              <url>https://repo1.maven.org/maven2</url>
              <releases>
                <enabled>true</enabled>
              </releases>
            </pluginRepository>
          </pluginRepositories>
        </profile>
      </profiles>
    
    
    安全中心
    安全中心
    中心的
    https://repo1.maven.org/maven2
    真的
    中心的
    https://repo1.maven.org/maven2
    真的
    
    我在许多不同的网络中遇到了相同的问题,这通常不会发生,因为您的互联网或网络,这就是Maven repo的问题,作为解决方案,我清理了本地.m repo目录,并通过Maven/更新Maven依赖项再次下载jar文件。
    这个问题将不复存在。这只是一次过程,不需要每次都这样做。

    为maven提供settings.xml文件,其中包含连接到存储库的用户ID和密码信息。settings.xml文件包含如下信息-

    <repository>
    <id>your_nexus_repo_id</id>
    <url>https://path_to_nexus_repo_location</url>
    <releases>
    <enabled>true</enabled>
    </releases>
    <snapshots>
    <enabled>true</enabled>
    </snapshots>
    </repository>
    
    <server>
      <id>dsnexus1</id>
          <username>your_user_id</username>
           <password>your_password</password>
    </server>
    
    
    您的\u nexus\u repo\u id
    https://path_to_nexus_repo_location
    真的
    真的
    dsnexus1
    您的\u用户\u id
    你的密码
    
    您可以在Eclipse中提供settings.xml文件,如下所示-

    <repository>
    <id>your_nexus_repo_id</id>
    <url>https://path_to_nexus_repo_location</url>
    <releases>
    <enabled>true</enabled>
    </releases>
    <snapshots>
    <enabled>true</enabled>
    </snapshots>
    </repository>
    
    <server>
      <id>dsnexus1</id>
          <username>your_user_id</username>
           <password>your_password</password>
    </server>
    
  • 在Eclipse IDE中,转到Windows>>首选项>>Maven>>用户设置
  • 使用浏览按钮在“用户设置”输入框中提供settings.xml。 您的settings.xml文件应位于/user home/.m2/文件夹中
  • 在此之后—

  • 右键单击您的项目
  • 转到-Maven>>更新项目
  • 单击“强制更新”,以便获得快照版本的最新副本
  • 现在,构建您的项目-

  • 右键单击您的项目
  • 转到以>>Maven构建方式运行
  • 提供目标:“干净安装”
  • 单击运行
  • 这将解决您的问题:)