mvn安装又出错了

问题描述 投票:0回答:6

mvn安装 我收到以下错误

[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its
 dependencies could not be resolved: Failed to read artifact descriptor for org.
apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact
 org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http:/
/repo.maven.apache.org/maven2): Connection to http://repo.maven.apache.org refus
ed: Connection timed out: 

我尝试使用堆栈中的早期答案设置代理,但我仍然面临问题。 需要明确的步骤帮助。

maven
6个回答
6
投票

解决方案:

将以下依赖项添加到 pom.xml:

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.5</version>
</dependency>

然后从命令提示符运行“mvn clean install”。

之后刷新 (F5) 并升级 eclipse 中的项目配置(运行 > Maven > 更新项目配置。)


2
投票

面临同样的问题。发生这种情况是因为缓存文件。对我有用的是删除存储库文件夹的内容。它确实在下一个版本中再次下载了所有文件,但解决了问题。


1
投票

在 .m2 文件夹中添加全局 settings.xml(示例将在您的 mvn.home/conf/settings.xml 中提供),该文件夹位于 c:/user/username/.m2 中。 在

<PluginRepositories>

内的 settings.xml 中添加以下条目
<pluginRepositories>
  <pluginRepository>
    <id>central</id>
    <name>Maven Plugin Repository</name>
    <url>http://repo1.maven.org/maven2</url>
    <releases>
      <enabled>false</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </pluginRepository>
</pluginRepositories>

这样就解决了上述问题。


0
投票

我也遇到了由代理设置引起的同样问题。我解决了这个问题,在位于

setting.xml
 的 maven 安装目录下的 
/conf/settings.xml

文件中添加了我的代理设置
<proxies>
    <proxy>
        <id>optional</id>
        <active>true</active>
        <protocol>http</protocol>
        <username>xxxx</username>
        <password>xxxxx</password>
        <host>xxxxxxx</host>
        <port>xxxx</port>
        <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
</proxies>

0
投票

我通过在我的

中包含以下几行解决了这个问题

设置.xml

文件可以在

C:\Program Files\Apache\maven\apache-maven-3.3.9\conf

找到
  <proxies>
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>https</protocol>
      <host>xxxxxxxxxx</host>
      <port>xxxx</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>

请注意协议 - “https”而不是“http”。保存此文件并通过导航至

更新 IDE 的用户设置

Windows->首选项->Maven->用户设置->用户设置

C:\Program Files\Apache\maven\apache-maven-3.3.9\conf\settings.xml

希望这有帮助。


-1
投票

在 Eclipse 中转到 Window-->Preferences-->Maven--> 取消选择选项“不自动更新远程存储库的依赖项”

这样做对我来说已经成功了。然后我就可以下载所有依赖项。

© www.soinside.com 2019 - 2024. All rights reserved.