Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven dependencies missing in Eclipse project

I have created a maven project on Eclipse but the maven dependencies library is missing but when I go to project->properties: Java Build Path I can see the maven dependencies library.

So because the maven dependencies is missing when I want to generate to project, I have BUILD SUCCESS but nothing is created.

like image 988
Anatch Avatar asked Mar 24 '15 16:03

Anatch


People also ask

How do I add Maven dependencies to an existing project in Eclipse?

Via the Maven index, you can search for dependencies, select them and add them to your pom file. To download the index, select Windows > Preferences > Maven and enable the Download repository index updates on startup option. After changing this setting, restart Eclipse. This triggers the download of the Maven index.

Where are Maven dependencies stored in Eclipse?

This folder contains your local Maven repository which is stored in ~/. m2/repository by default. It also contains a repository that represents the Maven projects contained in your Eclipse workspace.


3 Answers

Open the context menu for the project -> Maven -> Update Projects... and select your project. Maven will then refresh everything.

If this item isn't available, The m2e plugin of Eclipse hasn't recognized your project as a Maven project. If so, go to the context menu -> Configure -> Maven Nature.

Also try to build the project from the command line to make sure your POM actually works.

If you're missing dependencies, then check you POM (pom.xml) and make sure they are in there. To verify your dependencies, open the POM editor and select the "Dependency Hierarchy" tab (at the bottom) to get an overview.

like image 60
Aaron Digulla Avatar answered Oct 06 '22 01:10

Aaron Digulla


When you attempt to convert a Java project into a Maven project,Eclipse sometimes hoses the project and classpath files. Also, double check if Maven plugin (m2e) is installed. The plugin is a default for Eclipse Java, but not Eclipse EE.

Check you ".project" file if contains the following Maven reference.

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>sample</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.m2e.core.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.eclipse.m2e.core.maven2Nature</nature>
    </natures>
</projectDescription>

Also, double check your classpath.

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="target/classes" path="src/main/java">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" output="target/test-classes" path="src/test/java">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="output" path="target/classes"/>
</classpath>
like image 23
BK Batchelor Avatar answered Oct 05 '22 23:10

BK Batchelor


Open the .classpath file inside your eclipse project. Insert the following lines:

<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
</classpathentry> 

Then, rebuild your project at eclipse.
Project->Clean/Build

like image 37
yeaaaahhhh..hamf hamf Avatar answered Oct 06 '22 00:10

yeaaaahhhh..hamf hamf