eclipse 期间发生内部错误:“导入 Maven 项目”。java.lang.NullPointerException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13084379/
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
An internal error occurred during: "Importing Maven projects". java.lang.NullPointerException
提问by sandy
I am getting this error while importing a maven project in eclipse.I tried solution posted at herebut didn't get issue resolved.Not sure if pom is real culprit but just adding the code below
我在 eclipse 中导入 Maven 项目时遇到此错误。我尝试了在此处发布的解决方案,但没有解决问题。不确定 pom 是否真的是罪魁祸首,只是添加下面的代码
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>abc</groupId>
<artifactId>xyz</artifactId>
<packaging>jar</packaging>
<name>Selenium Test</name>
<build>
<finalName>selenium</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.25.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
回答by Badmash
There may be a spelling mistake with the project 'final name' or other declarations within the pom.xml. You could delete the project from the workspace then import it back. That should at least show some errors in console. You may get this error if you refractored your project name. Somehow, the refractor does not update the references.
pom.xml 中的项目“最终名称”或其他声明可能存在拼写错误。您可以从工作区中删除该项目,然后将其重新导入。那至少应该在控制台中显示一些错误。如果您折射了您的项目名称,您可能会收到此错误。不知何故,折射器不会更新参考。
回答by Gyanendra Dwivedi
It simply means that the pom.xml is having error. It could be simple spelling mistake or issue with some dependency. Here is a step wise approach, which may resolve your issue.
这只是意味着 pom.xml 有错误。这可能是简单的拼写错误或某些依赖性问题。这是一个循序渐进的方法,它可能会解决您的问题。
Step 1: Take backup of your existing pom.xml.
第 1 步:备份您现有的 pom.xml。
Step 2: Create a new project POM. You could use the below one as it is
第二步:新建项目POM。你可以按原样使用下面的
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>samplemaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Your dependencies goes here. -->
</dependencies>
</project>
Step 3: Change the groupId, artifatId etc (bare minimum changes required).
第 3 步:更改 groupId、artifatId 等(所需的最少更改)。
Step 4: Delete the .project, .classpath and .settings folder from the project directory (if you have these files are there earlier).
第 4 步:从项目目录中删除 .project、.classpath 和 .settings 文件夹(如果您之前有这些文件)。
Step 5: import the project in eclipse. You should not find any issue in importing.
第五步:在eclipse中导入项目。您应该不会在导入时发现任何问题。
Step 6: Once import is completed, change the new pom.xml to introduce other configuration from the old pom.xml (backed up in step 1).
第 6 步:导入完成后,更改新 pom.xml 以从旧 pom.xml(在第 1 步中备份)引入其他配置。
Do not replace the new pom.xml, as it most likely to bring back the original issue. Also be careful while retrofitting the changes to not to re-introduce the issue again.
不要替换新的 pom.xml,因为它很可能会带回原来的问题。在改造更改时也要小心,不要再次重新引入问题。
回答by 4EACH
I had the same error, i replace all the variables like in artifact and in version to the expected value and then the project imported perfectly, then i return back all the variables
我遇到了同样的错误,我将工件和版本中的所有变量替换为预期值,然后完美导入项目,然后我返回所有变量