7

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.

9 Answers 9

8

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.

Sign up to request clarification or add additional context in comments.

3 Comments

mvn eclipse:eclipse from the command line does well to update dependencies when all else fails
For executing cmd from the command line... cd <project location> Enter, then execute mvn eclipse:eclipse to update Maven Dependencies showing under your Package Explorer.
mvn eclipse:eclipse is old and should not be used.
6

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> 

1 Comment

I believe you are not supposed to have Maven repo referenced in the Eclipse project file. Proper place for those is in your Maven configuration (or in your pom.xml), that's where the Maven Eclipse plugin reads it from.
3

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

Comments

1

Check out whether your Maven dependencies are listed in Project properties -> Deployment Assembly, it should look something similar to this: enter image description here

Comments

1

Convert the project to Maven project in context menu. That is how I fixed it.

Comments

1

Right Click on the project. Click on "Build Project". It worked for me besides restart, refresh and all. Hope it works for you. Lemme know if it does.

Comments

0

Unfortunately, there is not much information here, I would suggest adding you pom.xml file if it is possible so that we can look at that to diagnose the exact issue.

As a stab in the dark, if you are not using a jar as your packaging eclipse can move the maven dependencies into a different folder in the interface. and example is 'war' packages have their maven dependencies moved to under "java resources/Libraries"

Usually the built project is under the 'target' file.

These are just guesses and I cant really tell you anything conclusive without additional information, sorry

4 Comments

Here is my pom.xml: <project xmlns="maven.apache.org/POM/4.0.0" xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:schemaLocation="maven.apache.org/POM/4.0.0 maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>CalculatriceAntlr</groupId> <artifactId>CalculatriceAntlr</artifactId> <version>0.0.1-SNAPSHOT</version> </project>
I think I have found my problem: In my pom.xml there is no dependencies included and do I need to write and include them manually in the pom.xml file ?
No, you don't write those. You add them to pom.xml using Maven POM Editor. (Usually that's what Eclipse opens your pom.xml with.) This editor has five "views", one of them is labelled "Dependencies".
I am able to get this pom to compile (after removing the semicolons), and after it compiles it is created in the 'target' folder, which is expected for the mvn install. Although the jar file does not appear in the eclipse interface. @AaronDiguella 's answer would be worth looking into, because I think it should solve the Dependencies not showing up problem. It might also be worth trying to refresh the project, as sometimes something does not get updated.
0

One extra thing to try:

I got this today using eclipse RAD when I did have a Maven nature and facets, and had followed all remedial steps listed above.

Eclipse had simply decided that I had no valid maven dependencies, and didn't show the "Maven Dependencies" element in the navigator window, even as an empty node. Rectifying the version on my one POM dependency to a version that it could find made the "Maven Dependencies" element magically appear with the one expected child.

Comments

0

This simply means your settings.xml file is corrupted. Just replace that file with valid content and your issue is resolved.

1 Comment

Welcome to StackOverflow. Your answer could be more useful if you added the full path to the file and the "valid content" that you mention. Or at least a similar example or some reference.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.