Import Maven Project to Eclipse and Fix the errors

60,494

Solution 1

The project that you imported is a Maven project. What you should do is open the pom.xml file located in the root of the project and add the following plugin in the plugin management part of the file:

<build>
    <pluginManagement>
        <plugins>
            <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-resources-plugin</artifactId>
                                    <versionRange>[2.0,)</versionRange>
                                    <goals>
                                        <goal>resources</goal>
                                        <goal>testResources</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore />
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

Then right click the project, go to Maven and Update project configuration.

This should fix it.

Solution 2

I think that your problem is not in maven project and not in import procedure but in your eclipse configuration. It seems that your eclipse "does not see" correct JDK.

So, first try to create the simple "hello world" project and see if it works. When this works import your maven project again, i.e. run command mvn eclipse:eclipse and then open the project using eclipse. If this is your first eclipse project you have to create M2_REPO variable that will refer to your maven repository (USER_HOME/.m2/repository)

If you still have problems try to refresh and clean the project.

If the problem still happens compare which JDK are you using in "good" and "bad" project. I believe that you will see difference there. So, fix it.

Solution 3

Were you able to build the project successfully.. If so, don't import it..again run @ project root level;

#mvn eclipse:eclipse -o  

This will create a eclipse project.Then 'import as existing project.' All classpath problem will get solved..But you need to set your .m2 home as a variable in your build path..

Solution 4

Go to Project->Properties->Java build path->Libraries. Is the JRE System Library added? Does it point to the correct location?

Also try running mvn eclipse:eclipse on the root folder of the project (You will need to download maven and add it to the classpath first).

Share:
60,494
Peril
Author by

Peril

Updated on October 15, 2021

Comments

  • Peril
    Peril over 2 years

    I made imported a project to eclipse and I have a lot of errors in every class name even classes like String ...

    the error in the classes I made is Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor

    and inside the methods <Class> cannot be resolved to a type even to IOException I am getting IOException cannot be resolved to a type

    so what should I do ? I tried to build , clean again with no use

    UPDATE : also I am getting Description

    Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-resources-plugin:2.4.3:resources (execution: default-resources, phase: process-resources)   pom.xml /test line 6    Maven Project Build Lifecycle Mapping Problem