java - intelliJ 中的 Maven 无法读取 Artifact 描述符 - 启用快照更新

标签 java maven intellij-idea

上周我的笔记本电脑更新到了 Windows 10。从那时起,intelliJ 抛出了 Maven 相关的错误,我一直无法解决这些错误。我的所有 Maven 插件都以红色突出显示,并显示错误:“无法读取(依赖项)的 Artifact 描述符。”。每个插件和依赖项都会发生这种情况。我还应该提到这是一个适用于其他所有人的克隆项目,因此问题不在于 pom。

这是我的 Maven 设置的屏幕截图: enter image description here

我尝试了很多选项来解决此问题,包括: 1. 使缓存失效/重启 2.重新导入项目 3.重新导入Maven依赖项。 4.删除intelliJ.iml和.idea文件夹。 5. 进行 Maven 全新安装(稍后会谈到这一点)。 6. 执行 git pull 并重新导入。 7.安装外部Maven(最新版本),将其添加到环境变量和intelliJ中。

下面是我尝试运行时控制台的错误输出:

"C:\Program Files (x86)\Java\jdk1.8.0_31\jdk1.8.0_31\bin\java" "-Dmaven.home=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.2\plugins\maven\lib\maven3\bin\m2.conf" -Didea.launcher.port=**** "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.4.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.2\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=2016.1.2 clean install
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for (redacted)
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 78, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building (redacted)SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.923s
[INFO] Finished at: Wed Jan 10 15:26:17 EST 2018
[INFO] Final Memory: 6M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

Process finished with exit code 1

CMD 提示尝试版本/全新/全新安装我得到以下结果:

C:\Users\(redacted)\(redacted)\(redacted)>mvn clean
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for (redacted)-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 73, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building (redacted) 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.697 s
[INFO] Finished at: 2018-01-11T10:09:44-05:00
[INFO] Final Memory: 7M/17M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

C:\Users\(redacted)\repos2\gpp-automated-testing>

最后,当我运行 mvn clean -e 查看详细错误时,我收到以下错误:

org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5

Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5

Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org

Caused by: org.apache.maven.wagon.TransferFailedException: repo.maven.apache.org

Caused by: java.net.UnknownHostException: repo.maven.apache.org

我尝试 ping 主机,但不确定哪一个是 ping 主机的正确方法,所以我尝试了所有方法。

C:\Users\(redacted)\repos2\(redacted)>ping http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
Ping request could not find host http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom. Please check the name and try again.

C:\Users\(redacted)\repos2\(redacted)>ping http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
Ping request could not find host http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom. Please check the name and try again.
C:\Users\(redacted)\repos2\(redacted)>ping http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/
Ping request could not find host http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/. Please check the name and try again.
C:\Users\(redacted)\repos2\(redacted)>ping http://repo.maven.apache.org
Ping request could not find host http://repo.maven.apache.org. Please check the name and try again.

最佳答案

好吧...您遇到了 DNS 问题...这意味着逻辑名称:repo.maven.apache.org 无法转换为 IP 地址...这是一个问题你的操作系统和网络管理员...所以你的pom和intellij没问题...

更新: 如果您有公司存储库,则需要在 .m2/settings.xml 文件中添加公司存储库...在 Windows 中,该文件夹位于您的用户系统文件夹

关于java - intelliJ 中的 Maven 无法读取 Artifact 描述符 - 启用快照更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48210453/

相关文章:

java - 为什么旋转窗口的背景在 Mac 而不是 Windows 上发生变化?

java - 对三个不同的应用程序给予同等的优先级

java - 线程 "main"java.lang.NoSuchMethodError : scala. Predef$.refArrayOps(

intellij-idea - Play 框架和 IntelliJ 新项目创建——错误

java - 主意。如何从外部文件导入 code_scheme?

java - Java UDP中如何获取实际数据包大小 `byte[]`数组

java - float 大于或小于零

java - Spring MVC 保存后恢复页面状态

scala - 使用SBT将生成的JAR文件发布到Maven

maven - 无法从 Maven 测试单元中调用 sun.security.tools.keytool.Main