简体   繁体   English

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

[英]Problems after Maven installation - mvn install tries to download unreachable files

After installing maven ( mvn -v works fine), I tried to do mvn install in a directory having a good pom.xml at the root of a Maven project that I know works. 安装maven之后( mvn -v可以正常工作),我尝试在我知道可以正常运行的Maven项目的根目录下,将mvn install在一个具有良好pom.xml的目录中。

I get the output shown at the bottom which basically states that it tried to download a file from an online maven repository and failed. 我得到的输出显示在底部,该输出基本上表明它尝试从在线Maven存储库下载文件并失败。 The file appears to be maven-oriented and I don't think it's related to my project. 该文件似乎是面向Maven的,我认为它与我的项目无关。

In addition, if I run mvn install in a directory without a pom.xml , which should just fail as I understand it, I get the same problems. 另外,如果我在没有pom.xml的目录中运行mvn install ,那么按照我的理解它应该会失败,我也会遇到同样的问题。 I'm guessing my Maven just hasn't been fully set up yet and its configuring itself maybe? 我猜我的Maven尚未完全设置好,它本身是否可以配置?

Can anyone tell me why it wants these files, and why it might be failing? 谁能告诉我为什么它想要这些文件,以及为什么它可能会失败?

I seem to have access to the URL in chrome and the file being targeted is there, so even if it does need it, I'm baffled about why the download is failing. 我似乎可以访问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

Your gateway is blocking maven from downloading the dependencies. 您的网关阻止Maven下载依赖项。

Try and check whether you are able to download this pom file manually. 尝试检查是否可以手动下载此pom文件。

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

if you are open the above URL from your browser, then check your firewall settings(Sometimes firewall settings also block maven from downloading the dependencies, especially if you are in an enterprise environment). 如果从浏览器打开上述URL,则检查防火墙设置(有时防火墙设置还会阻止Maven下载依赖项,尤其是在企业环境中)。

if that is the case, you need to use a proxy to bypass your gateway and download the dependencies 如果是这种情况,则需要使用代理绕过网关并下载依赖项

OR 要么

Download the plugins manually from maven central or nexus repository and install it using maven install command in your local .m2 directory. 从maven Central或nexus存储库中手动下载插件,并使用maven install命令在本地.m2目录中进行安装。

maven install -DartifactId="your dependency" -DgroupId="groupID of the dependency" -DFile="your file location" maven install -DartifactId =“您的依赖项” -DgroupId =“该依赖项的组ID” -DFile =“您的文件位置”

As you mentioned in the comments that you are able to open the site from chrome, you can install the dependency using the above command. 正如您在评论中提到的,您可以从chrome打开网站,您可以使用上述命令安装依赖项。

Unable to download the artifact from any repository maven: 无法从任何存储库专家下载工件:

Check for proxy :if you have some customized jar file related to your company project ,it needs your firewall and if you are using any proxy in setting.xml file then block it to get it downloaded. 检查代理:如果您有一些与公司项目相关的自定义jar文件,则它需要您的防火墙,并且如果您在setting.xml文件中使用任何代理,则将其阻止以进行下载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM