15

我在正确配置我的 Eclipse 以使用 Maven 时遇到了一些问题。

我创建了一个新项目,这个项目是在命令行(mvn install)中使用 maven 正确构建的,但是在 Eclipse 中我收到了这个错误:

CoreException:无法获取插件执行默认编译的参数 compilerId 的值:PluginResolutionException:插件 org.apache.maven.plugins:maven-compiler-plugin:3.1 或其依赖项之一无法解析:无法收集依赖项org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 (): ArtifactDescriptorException: 无法读取 org.apache.maven:maven-settings:jar:2.2.1 的工件描述符: ArtifactResolutionException: 传输 org 失败.apache.maven:maven-settings:pom:2.2.1 来自http://repo.maven.apache.org/maven2被缓存在本地存储库中,直到中央的更新间隔过去或强制更新后才会重新尝试解析。原始错误:无法将工件 org.apache.maven:maven-settings:pom:2.2.1 从/到中央传输:NullPointerException pom.xml /test line 9 Maven Project Build Lifecycle Mapping Problem

这是我的 settings.xml conf:

<proxy>
  <active>true</active>
  <protocol>http</protocol>
  <username>myuser</username>
  <password>$mymdp</password>
  <host>myhost</host>
  <port>8080</port>
  <nonProxyHosts>some.host.com</nonProxyHosts>
</proxy>
....

<repository>
     <id>central</id>
     <name>central repo m2</name>
     <url>http://central.maven.org/maven2</url>
</repository>

我选择了正确的 Maven 安装(在 Preference -> Maven -> Install 中)

我还将我的用户设置指向正确的 settings.xml (Preferences -> Maven -> User Settings)

但是我仍然在 Eclipse 中遇到了这个错误,并且在 Maven 命令行中一切正常。你有想法吗?

4

7 回答 7

10

您是否尝试过删除代理用户名和密码?一个类似的海报遇到了这个问题:

无法计算构建计划:无法解析插件 org.apache.maven.plugins:maven-jar-plugin:2.3.2 或其依赖项之一

失败,我发现以下工作:

  1. 在 Eclipse 中删除项目(但不要删除磁盘上的内容)
  2. 删除 Maven 存储库中的所有文件
  3. 重新下载所有 Maven 依赖项:

mvn 依赖:解决

  1. 启动 Eclipse
  2. 确保将 Eclipse 配置为使用您的外部 Maven 安装(Window->Preferences->Maven->Installations)
  3. 将现有项目重新导入 Eclipse
  4. 确保项目导入的最终屏幕上没有 Maven Eclipse 插件错误
于 2014-03-13T08:19:29.113 回答
10

您只需要删除一个引发错误的文件夹。只需转到您的 M2 存储库和 org/apache/maven/plugins/maven-compiler-plugins 并删除文件夹 2.3.2

于 2017-02-16T02:39:35.210 回答
3

我在构建全新的开发机器时使用 IBM RSA 9.6.1 时遇到了这个问题。对我来说问题最终是因为全球 Maven 存储库上的 HTTPS。我的解决方案是创建一个强制它使用 HTTP 的 Maven settings.xml。

对我来说关键是当我在 Maven Repositories --> Global Repositories 下展开中央存储库时它是空的

使用以下设置文件对我有用:

<settings>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>insecurecentral</activeProfile>
  </activeProfiles>
  <profiles>
    <profile>
      <id>insecurecentral</id>
      <!--Override the repository (and pluginRepository) "central" from the Maven Super POM -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://repo.maven.apache.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://repo.maven.apache.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
</settings>

我从这个stackoverflow问题中得到了这个想法。

于 2018-02-15T20:05:08.170 回答
1

Maven 设置的安装在 Eclipse 中作为外部提供时,该问题已得到解决。导航设置是 Window --> Preferences --> Installations。选择 External 作为安装类型,提供 Installation home 和名称,然后单击 Finish。最后选择这个作为默认安装。

于 2016-08-25T14:03:58.260 回答
0

我也遇到了同样的问题,无法创建 jar,我发现在 Windows-->Prefernces-->Java-->installed JREs 默认情况下,JRE 已添加到新创建的 java 项目的构建路径中,所以只是更改了它到您喜欢的JDK。

于 2020-12-26T10:53:26.203 回答
0

我不小心打开了离线模式。

要禁用它:在 Maven 工具窗口中,单击 Toggle Offline Mode 按钮。

在此处输入图像描述

于 2021-01-22T05:34:41.930 回答
0

找到您的 Maven 本地存储库,导航到 maven-compiler-plugin,删除 3.8.1 文件夹,以便 Maven 重新下载它。

例如:C:\Users\mkyong.m2\repository\org\apache\maven\plugins\maven-compiler-plugin

于 2022-01-19T15:18:05.810 回答