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.
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.
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.
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.
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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With