将Maven项目导入Eclipse会出错

时间:2015-11-11 04:22:44

标签: eclipse maven nullpointerexception

NullPointerException

java.lang.NullPointerException
        at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.isContained(AbstractJavaProjectConfigurator.java:470)
        at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.isNonOverlappingResourceDescriptor(AbstractJavaProjectConfigurator.java:461)
        at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.addResourceDirs(AbstractJavaProjectConfigurator.java:422)
        at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.addProjectSourceFolders(AbstractJavaProjectConfigurator.java:299)
        at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.configure(AbstractJavaProjectConfigurator.java:122)
        at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:120)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$3.call(ProjectConfigurationManager.java:501)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$3.call(ProjectConfigurationManager.java:1)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:494)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.configureNewMavenProjects(ProjectConfigurationManager.java:281)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$1.call(ProjectConfigurationManager.java:168)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$1.call(ProjectConfigurationManager.java:1)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
        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.embedder.MavenImpl.execute(MavenImpl.java:1355)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.importProjects(ProjectConfigurationManager.java:136)
        at org.eclipse.m2e.core.ui.internal.wizards.ImportMavenProjectsJob$1.doCreateMavenProjects(ImportMavenProjectsJob.java:68)
        at org.eclipse.m2e.core.ui.internal.wizards.AbstractCreateMavenProjectsOperation.run(AbstractCreateMavenProjectsOperation.java:62)
        at org.eclipse.m2e.core.ui.internal.wizards.ImportMavenProjectsJob.runInWorkspace(ImportMavenProjectsJob.java:77)
        at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

我尝试了mvn eclipse:eclipse然后导入到Eclipse(导入现有的maven项目)但它仍然抛出NullPointerException

由于

2 个答案:

答案 0 :(得分:4)

这似乎是m2e中的一个错误。您的项目可能包括对外部资源的引用。就我而言,它是父项目中的资源:

  <resource>
    <directory>..</directory>
    <includes>
      <include>LICENSE</include>
      <include>NOTICE</include>
    </includes>
  </resource>

将目录规范从..更改为$ {project.parent.basedir}摆脱了我的例外。

答案 1 :(得分:1)

当我遇到这个问题时,我正在使用Eclipse MARS / M2E 1.6.2 / JDK 1.8u66。如果您不介意使用较旧的M2E,则降级M2E 1.5.2可以解决这个问题。

安装软件时只需使用以下链接即可。 http://download.eclipse.org/technology/m2e/releases/1.5/1.5.2.20150413-2215