Java 使用 Maven 生成 Eclipse 项目文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3131285/
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-08-13 16:42:36  来源:igfitidea点击:

generating Eclipse project files with Maven

javaeclipsemaven-2

提问by Dónal

When I try and generate the Eclipse project files using mvn eclipse:eclipseI get the following error:

当我尝试使用生成 Eclipse 项目文件时mvn eclipse:eclipse,出现以下错误:

Internal error in the plugin manager executing goal 'org.apache.maven.plugins:maven-eclipse-plugin:2.9-SNAPSHOT:eclipse': Unable to load the mojo 'org.apache.maven.plugins:maven-eclipse-plugin:2.9-SNAPSHOT:eclipse' in the plugin 'org .apache.maven.plugins:maven-eclipse-plugin'. A required class is missing: org/codehaus/plexus/resource/loader/ResourceNotFoundException

插件管理器执行目标“org.apache.maven.plugins:maven-eclipse-plugin:2.9-SNAPSHOT:eclipse”中的内部错误:无法加载 mojo 'org.apache.maven.plugins:maven-eclipse-plugin:插件'org .apache.maven.plugins:maven-eclipse-plugin'中的2.9-SNAPSHOT:eclipse'。缺少必需的类:org/codehaus/plexus/resource/loader/ResourceNotFoundException

It appears that I'm using version 2.9-SNAPSHOT of the Maven Eclipse plugin. My guess is that there is a bug in this version of the plugin and if I use a stable release (instead of a snapshot), the problem will be resolved. Is there a way that I can change the version of this plugin I'm using, or is this problem unrelated to the version of the Eclipse plugin?

看来我正在使用 Maven Eclipse 插件的 2.9-SNAPSHOT 版本。我的猜测是这个版本的插件存在错误,如果我使用稳定版本(而不是快照),问题将得到解决。有没有办法可以更改我正在使用的这个插件的版本,或者这个问题是否与 Eclipse 插件的版本无关?

采纳答案by Pascal Thivent

Either use the fully qualified name of the plugin to specify the version:

使用插件的完全限定名称来指定版本:

$ mvn org.apache.maven.plugins:maven-eclipse-plugin:2.8:eclipse

Or edit the ~/.m2/plugin-registry.xmlfile (for advanced users, make a backup).

或编辑~/.m2/plugin-registry.xml文件(对于高级用户,请进行备份)。

Or try the -npr,--no-plugin-registryoptions to tell maven to not use ~/.m2/plugin-registry.xmlfor plugin versions:

或者尝试-npr,--no-plugin-registry告诉 maven 不使用~/.m2/plugin-registry.xml插件版本的选项:

$ mvn -npr eclipse:eclipse

But I don't guarantee a successful result. See the Introduction to the Plugin Registryfor more details.

但我不保证成功的结果。有关更多详细信息,请参阅插件注册表简介

Or remove the version 2.9-SNAPSHOTfrom your local repository:

或者2.9-SNAPSHOT从本地存储库中删除版本:

$ rm -rf ~/.m2/repository/org/apache/maven/plugins/maven-eclipse-plugin/2.9-SNAPSHOT

回答by Gregor

Unfortunately the problem still persists and the selected answer did not help me, as Maven always wanted to fetch the newest version available, which is the faulty 2.9-SNAPSHOT.

不幸的是,问题仍然存在,所选的答案对我没有帮助,因为 Maven 一直想获取可用的最新版本,这是有问题的 2.9-SNAPSHOT。

I had to manually specify the working version 2.8 in my POM, like so:

我必须在我的 POM 中手动指定工作版本 2.8,如下所示:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-eclipse-plugin</artifactId>
   <version>2.8</version>
   <configuration>
...

回答by Flore

The solutions mentioned in the accepted answer does not seems to work. Using no plugin registry, it always tries to use the latest version, and re-download it you try to delete it.

接受的答案中提到的解决方案似乎不起作用。不使用插件注册表,它总是尝试使用最新版本,然后重新下载并尝试删除它。

I solved the problem by updating the file

我通过更新文件解决了这个问题

.m2/repository/org/apache/maven/plugins/maven-eclipse-plugin/maven-metadata-central.xml

.m2/repository/org/apache/maven/plugins/maven-eclipse-plugin/maven-metadata-central.xml

You're not supposed to edit this file, but if it was using the 2.9-SNAP instead of 2.9, it probably means that this file specified 2.9-SNAP at the latest instead of the 2.9

您不应该编辑此文件,但如果它使用的是 2.9-SNAP 而不是 2.9,则可能意味着此文件最晚指定了 2.9-SNAP 而不是 2.9