java - Maven 安装后出现问题 - mvn install 尝试下载无法访问的文件

标签 java maven deployment build

安装 maven 后(mvn -v 工作正常),我尝试在一个目录中执行 mvn install,该目录在我知道有效的 Maven 项目根目录下有一个良好的 pom.xml

我得到底部显示的输出,基本上表明它尝试从在线 Maven 存储库下载文件但失败了。该文件似乎是面向 maven 的,我认为它与我的项目无关。

此外,如果我在没有 pom.xml 的目录中运行 mvn install (按照我的理解,这应该会失败),我也会遇到同样的问题。我猜我的 Maven 还没有完全设置好,它可能会自行配置?

谁能告诉我为什么它需要这些文件,以及为什么它可能会失败?

我似乎可以访问 Chrome 中的 URL,并且目标文件就在那里,所以即使它确实需要它,我也对下载失败的原因感到困惑。

C:\>mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-resources-plugin:pom:2.3' from repository central (http://repo1.maven.org/maven2): Error transferring file: Connection timed out: conne
ct
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-resources-plugin:pom:2.3' from repository central (http://repo1.maven.org/maven2): Error transferring file: Connection timed out: conne
ct
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.apache.maven.plugins:maven-resources-plugin

Reason: POM 'org.apache.maven.plugins:maven-resources-plugin' not found in repository: Unable to download the artifact from any repository

  org.apache.maven.plugins:maven-resources-plugin:pom:2.3

from the specified remote repositories:
  central (http://repo1.maven.org/maven2)

 for project org.apache.maven.plugins:maven-resources-plugin

最佳答案

您的网关阻止 Maven 下载依赖项。

尝试检查是否可以手动下载此 pom 文件。

http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom

如果您从浏览器打开上述 URL,请检查您的防火墙设置(有时防火墙设置也会阻止 Maven 下载依赖项,尤其是在企业环境中)。

如果是这种情况,您需要使用代理绕过网关并下载依赖项

或者

从 maven 中央或 nexus 存储库手动下载插件,并使用 maven install 命令将其安装在本地 .m2 目录中。

maven install -DartifactId="your dependency" -DgroupId="groupID of the dependency" -DFile="your file location"

正如您在评论中提到的,您可以从 Chrome 打开该网站,您可以使用上述命令安装依赖项。

关于java - Maven 安装后出现问题 - mvn install 尝试下载无法访问的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12807112/

相关文章:

deployment - 使用 CLI 自动设置 jenkins 用户

java - 我的 Netbeans 没有显示我的 GUI

java.lang.IllegalStateException : Not on FX application thread; currentThread = Thread-4

java - 向 iText PDF block 添加空格

java - Maven “Always update snapshots” 的 IntelliJ 2017.2 设置有什么作用?

java.lang.IncompleteClassChangeError : the number of constructors

java - 如何处理多环境构建?

java - 从 JSONException 中恢复

java - Apache Poi 3.13 找不到打开 XLSX 文件的类

java - 部署带有图像的 jar 文件时遇到问题