Thursday, August 23, 2012

Resolving Maven dependencies in eclipse

In order to resolve Maven dependencies in eclipse variable M2_REPO should be added to the classpath variables of the eclipse.

We can check the list classpath variables in eclipse at

Window ->Preferences->Java->Build Path ->Classpath Variables

In this view new classpath variable M2_REPO can be added directly. It should point to the location of Maven repository and not the home location of Maven



Other way is to do through console.

Run command:

mvn -Declipse.workspace="Your Workspace" eclipse:configure-workspace

It will add the variable in eclipse workspace.

mvn -Declipse.workspace="C:\Users\aggara4\SpringWorkSpace" eclipse:configure-workspace


[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SampleWebProject Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-eclipse-plugin:2.9:configure-workspace (default-cli) @ SampleWebProject ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.015s
[INFO] Finished at: Thu Aug 23 13:47:12 IST 2012
[INFO] Final Memory: 5M/9M
[INFO] ------------------------------------------------------------------------