org.eclipse.m2e.core插件在Eclipse中遇到NullPointerException

时间:2018-05-22 12:44:16

标签: eclipse eclipse-plugin m2e

在Eclipse Oxygen中导入了一个maven项目,并在构建项目时使用 org.eclipse.m2e.core 插件解决了这个问题。 m2e版本是1.8.3,有人知道为什么会这样吗?我已经从错误报告中看到了类似的问题,但从版本1.1开始它们被标记为已修复。

java.lang.NullPointerException
at org.eclipse.m2e.core.internal.lifecyclemapping.model.PluginExecutionMetadata.getAction(PluginExecutionMetadata.java:144)
at org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.isConfigurator(LifecycleMappingFactory.java:718)
at org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata0(LifecycleMappingFactory.java:602)
at org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(LifecycleMappingFactory.java:535)
at org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(LifecycleMappingFactory.java:249)
at org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.calculateLifecycleMapping(LifecycleMappingFactory.java:181)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.setupLifecycleMapping(ProjectRegistryManager.java:594)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refreshPhase2(ProjectRegistryManager.java:513)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:492)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:496)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:351)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:298)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.getProjectFacade(MavenBuilder.java:154)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:89)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86)

此外,如果您真的去尝试查看代码:

https://github.com/eclipse/m2e-core/tree/m2e-1.8.x/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping

这个套餐似乎甚至不存在? WTH正在进行中吗?这个项目是否已经分裂到地狱,我在错误的地方寻找?我应该打包并开始使用IntelliJ,似乎m2e在Eclipse中变得无法管理。生命周期映射在父

中定义
  <pluginManagement>
    <plugin>
      <groupId>org.eclipse.m2e</groupId>
      <artifactId>lifecycle-mapping</artifactId>
      <version>1.0.0</version>
      <configuration>
        <lifecycleMappingMetadata>
          <pluginExecutions>
            <pluginExecution>
              <pluginExecutionFilter>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <versionRange>[2.10,)</versionRange>
                <goals>
                  <goal>unpack-dependencies</goal>
                </goals>
              </pluginExecutionFilter>
            </pluginExecution>
          </pluginExecutions>
        </lifecycleMappingMetadata>
      </configuration>
    </plugin>
  </pluginManagement>

1 个答案:

答案 0 :(得分:1)

使用modello

从{{3}}生成PluginExecutionMetadata

NPE发生的生成代码中的行是

org.codehaus.plexus.util.xml.Xpp3Dom actionDom = ((org.codehaus.plexus.util.xml.Xpp3Dom) getActionDom()).getChild(0);

这指向了答案:在您的xml代码段中,缺少必需的<action>标记,例如像:

             </pluginExecutionFilter>
             <action>
               <ignore/>
             </action>
           </pluginExecution>