Eclipse 中的 M2E 出现 maven-compiler-plugin 错误,但 Maven 安装没问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36581189/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:08:23  来源:igfitidea点击:

M2E in Eclipse gives maven-compiler-plugin errors, but Maven installation is fine

javaeclipsemavenm2eclipse

提问by 08robertsj

I've installed Maven 3.3.9 and I'm running Eclipse Mars 2 with JDK 1.8.0_65.

我已经安装了 Maven 3.3.9 并且我正在运行带有 JDK 1.8.0_65 的 Eclipse Mars 2。

I've tried to create a Maven Project, yet it always returns four errors:

我试图创建一个 Maven 项目,但它总是返回四个错误:

Description Resource    Path    Location    Type
CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 -> org.codehaus.plexus:plexus-container-default:jar:1.5.5 -> org.apache.xbean:xbean-reflect:jar:3.4 -> log4j:log4j:jar:1.2.12: ArtifactDescriptorException: Failed to read artifact descriptor for log4j:log4j:jar:1.2.12: ArtifactResolutionException: Failure to transfer log4j:log4j:pom:1.2.12 from https://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 log4j:log4j:pom:1.2.12 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled.   pom.xml /PluginBasedPasswords   line 1  Maven Project Build Lifecycle Mapping Problem

I get a similar error to the one above but for plugin execution default-testCompile

我得到了与上述类似的错误,但对于插件执行 default-testCompile

The other two (one for default-compile and the other for default-testCompile) have a structure like this:

另外两个(一个用于 default-compile,另一个用于 default-testCompile)具有如下结构:

Description Resource    Path    Location    Type
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (execution: default-compile, phase: compile)    pom.xml /PluginBasedPasswords   line 1  Maven Project Build Lifecycle Mapping Problem

The project creation wizard shows me a similar version:

项目创建向导向我展示了一个类似的版本:

Import Maven Projects GUI showing the errors I'm receiving.

显示我收到的错误的导入 Maven 项目 GUI。

I've followed several tutorials for installing Maven and setting my environment variables so I doubt it is them (if needed: PATH: C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Maven\apache-maven-3.3.9\bin;;C:\Program Files\Java\jdk1.8.0_65\bin;C:\Program Files\Java\jre1.8.0_73;, M2_HOME: C:\Program Files\Maven\apache-maven-3.3.9and JAVA_HOME: C:\Program Files\Java\jdk1.8.0_65)

我已经遵循了几个安装 Maven 和设置我的环境变量的教程,所以我怀疑是它们(如果需要: PATH: C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Maven\apache-maven-3.3.9\bin;;C:\Program Files\Java\jdk1.8.0_65\bin;C:\Program Files\Java\jre1.8.0_73;, M2_HOME:C:\Program Files\Maven\apache-maven-3.3.9和 JAVA_HOME: C:\Program Files\Java\jdk1.8.0_65

My Maven installation seems to be functional because running mvn -versionreturns:

我的 Maven 安装似乎可以正常运行,因为运行mvn -version返回:

C:\Windows\system32>mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:4
7+00:00)
Maven home: C:\Program Files\Maven\apache-maven-3.3.9
Java version: 1.8.0_65, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_65\jre
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"

I've also updated my M2E plugin via the Esclipse Marketplace so I truly have no idea what's going wrong. Any help?

我还通过 Esclipse 市场更新了我的 M2E 插件,所以我真的不知道出了什么问题。有什么帮助吗?

回答by 08robertsj

It turns out that I didn't have the most up-to-date version of M2E. So to solve this, I uninstalled all versions of M2E that came with Eclipse. Then I followed the instructions on http://download.eclipse.org/technology/m2e/releases

事实证明,我没有最新版本的 M2E。所以为了解决这个问题,我卸载了 Eclipse 附带的所有版本的 M2E。然后我按照http://download.eclipse.org/technology/m2e/releases上的说明进行操作

However, I had previously just added that exact URL to Eclipse's Install New Software dialogue. What you have to do instead is click the link to Show Directory Contentsand select the version of M2E you wish to use. In this case, it was 1.6. Then you select the most recent sub-version.

但是,我之前刚刚将那个确切的 URL 添加到 Eclipse 的安装新软件对话框中。您需要做的是单击显示目录内容的链接,然后选择您希望使用的 M2E 版本。在这种情况下,它是 1.6。然后选择最新的子版本。

Once done, copy the new URL from your browser and add it to the install software dialogue. The URL in this case was http://download.eclipse.org/technology/m2e/releases/1.6/1.6.2.20150902-0002/?d. Once this was done, everything suddenly worked!

完成后,从浏览器复制新 URL 并将其添加到安装软件对话框中。本例中的 URL 是http://download.eclipse.org/technology/m2e/releases/1.6/1.6.2.20150902-0002/?d。一旦这样做了,一切都突然奏效了!

Hope that has helped someone in my situation.

希望对我这种情况的人有所帮助。